Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@pake/close-with-grace
Advanced tools
Exit your process, gracefully (if possible) - for Node.js
npm i close-with-grace
const closeWithGrace = require('close-with-grace')
// delay is the number of milliseconds for the graceful close to
// finish.
closeWithGrace({ delay: 500 }, async function ({ signal, err, manual }) {
if (err) {
console.error(err)
}
await closeYourServer()
})
const closeWithGrace = require('close-with-grace')
// delay is the number of milliseconds for the graceful close to
// finish.
closeWithGrace(
{
delay: 500,
logger: { error: (m) => console.error(`[close-with-grace] ${m}`) }
},
async function ({ signal, err, manual }) {
if (err) {
console.error(err)
}
await closeYourServer()
})
closeWithGrace([opts], fn({ err, signal, manual }))
closeWithGrace
adds a global listeners to the events:
process.once('SIGTERM')
process.once('SIGINT')
process.once('uncaughtException')
process.once('unhandledRejection')
In case one of them is emitted, it will call the given function. If it is emitted again, it will terminate the process abruptly.
delay
: the numbers of milliseconds before abruptly close the
process. Default: 10000
.
logger
: instance of logger which will be used internally. Default: console
.
Execute the given function to perform a graceful close.
The function can either return a Promise
or call the callback.
If this function does not error, the process will be closed with
exit code 0
.
If the function rejects with an Error
, or call the callback with an
Error
as first argument, the process will be closed with exit code
1
.
Calling closeWithGrace()
will return an object as formed:
close()
: close the process, the manual
argument will be set to
true.uninstall()
: remove all global listeners.MIT
FAQs
Exit your process, gracefully (if possible)
We found that @pake/close-with-grace demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.