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
99.7
Supply Chain
91.6
Quality
78.2
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
189 Stars
119 Commits
22 Forks
11 Watching
6 Branches
15 Contributors
Updated on 18 Nov 2024
TypeScript (74.85%)
JavaScript (24.53%)
Shell (0.62%)
Cumulative downloads
Total Downloads
Last day
-6.5%
17,339,494
Compared to previous day
Last week
1.7%
100,591,932
Compared to previous week
Last month
10.7%
414,917,541
Compared to previous month
Last year
68.9%
3,937,117,753
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
6 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
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
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 2024-11-18
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