Skip to content

Commit f52166c

Browse files
abort signal on both beforeExit and exit
1 parent e1934ce commit f52166c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/libraries/AbortSignal.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
const DBDestroySignal = new AbortController();
22

3-
process.on('beforeExit', () => {
4-
DBDestroySignal.abort('Process is exiting')
5-
})
3+
function abortSignal() {
4+
if (!DBDestroySignal.signal.aborted) {
5+
DBDestroySignal.abort('Process is exiting')
6+
}
7+
}
8+
9+
process.on('beforeExit', abortSignal)
10+
process.on('exit', abortSignal)
611

712
export default DBDestroySignal;

0 commit comments

Comments
 (0)