Skip to content

Commit

Permalink
increment by old signal-exit's count, not just 1
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 29, 2023
1 parent 8fa7fc9 commit f619d7c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,18 @@ class SignalExit extends SignalExitBase {
// exit v4 are not aware of each other, and each will attempt to let
// the other handle it, so neither of them do. To correct this, we
// detect if we're the only handler *except* for previous versions
// of signal-exit.
// of signal-exit, and increment by the count of listeners it has
// created.
/* c8 ignore start */
//@ts-ignore
if (typeof process.__signal_exit_emitter__ === 'object') count++
const p = process as unknown as {
__signal_exit_emitter__?: { count: number }
}
if (
typeof p.__signal_exit_emitter__ === 'object' &&
typeof p.__signal_exit_emitter__.count === 'number'
) {
count += p.__signal_exit_emitter__.count
}
/* c8 ignore stop */
if (listeners.length === count) {
this.unload()
Expand Down

0 comments on commit f619d7c

Please sign in to comment.