Gathering detailed insights and metrics for signal-exit
Gathering detailed insights and metrics for signal-exit
Gathering detailed insights and metrics for signal-exit
Gathering detailed insights and metrics for signal-exit
when you want to fire an event no matter how a process exits.
npm install signal-exit
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.7
Supply Chain
91.6
Quality
78.2
Maintenance
100
Vulnerability
100
License
TypeScript (74.85%)
JavaScript (24.53%)
Shell (0.62%)
Total Downloads
14,473,593,885
Last Day
21,765,493
Last Week
124,900,255
Last Month
599,927,899
Last Year
5,136,912,151
ISC License
192 Stars
119 Commits
23 Forks
10 Watchers
6 Branches
15 Contributors
Updated on Jul 06, 2025
Latest Version
4.1.0
Package Id
signal-exit@4.1.0
Unpacked Size
75.16 kB
Size
13.06 kB
File Count
29
NPM Version
9.7.2
Node Version
18.16.0
Published on
Jul 29, 2023
Cumulative downloads
Total Downloads
Last Day
-0.1%
21,765,493
Compared to previous day
Last Week
-8.8%
124,900,255
Compared to previous week
Last Month
15.6%
599,927,899
Compared to previous month
Last Year
57%
5,136,912,151
Compared to previous year
When you want to fire an event no matter how a process exits:
process.exit(code)
called.process.kill(pid, sig)
called.Use signal-exit
.
1// Hybrid module, either works 2import { onExit } from 'signal-exit' 3// or: 4// const { onExit } = require('signal-exit') 5 6onExit((code, signal) => { 7 console.log('process exited!', code, signal) 8})
remove = onExit((code, signal) => {}, options)
The return value of the function is a function that will remove the handler.
Note that the function only fires for signals if the signal would cause the process to exit. That is, there are no other listeners, and it is a fatal signal.
If the global process
object is not suitable for this purpose
(ie, it's unset, or doesn't have an emit
method, etc.) then the
onExit
function is a no-op that returns a no-op remove
method.
alwaysLast
: Run this handler after any other signal or exit
handlers. This causes process.emit
to be monkeypatched.If the handler returns an exact boolean true
, and the exit is a
due to signal, then the signal will be considered handled, and
will not trigger a synthetic process.kill(process.pid, signal)
after firing the onExit
handlers.
In this case, it your responsibility as the caller to exit with a
signal (for example, by calling process.kill()
) if you wish to
preserve the same exit status that would otherwise have occurred.
If you do not, then the process will likely exit gracefully with
status 0 at some point, assuming that no other terminating signal
or other exit trigger occurs.
Prior to calling handlers, the onExit
machinery is unloaded, so
any subsequent exits or signals will not be handled, even if the
signal is captured and the exit is thus prevented.
Note that numeric code exits may indicate that the process is already committed to exiting, for example due to a fatal exception or unhandled promise rejection, and so there is no way to prevent it safely.
The 'signal-exit/browser'
module is the same fallback shim that
just doesn't do anything, but presents the same function
interface.
Patches welcome to add something that hooks onto
window.onbeforeunload
or similar, but it might just not be a
thing that makes sense there.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
8 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More