
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Gracy is a zero-dependency library that provides a simple way to execute custom functions before a Node.js process exits. It helps you ensure that your applications perform cleanup tasks, gracefully close resources, and maintain data integrity during (un)expected shutdowns or terminations.
pnpm i gracy
import { onExit } from 'gracy'
onExit(
{ logger: pinoInstance },
// Supports sync/async functions
closeHttpServer,
closeDatabaseConnection
)
The onExit
function accepts an configuration object as its first argument. The following options are available:
Name | Default value | Description |
---|---|---|
logger | Logger to use. You should use libraries for structured logging such as pino, but you can also use the built-in console object. Set to false to disable logging. | |
events | ['uncaughtException', 'unhandledRejection'] | Events to listen to. Triggering these events will cause the process to exit with code 1 . |
signals | ['SIGTERM', 'SIGINT'] | Signals to listen to. Triggering these signals will cause the process to exit with code 0 . |
This project has been scaffolded with create-npm-library.
FAQs
Execute custom cleanup function before Node.js exits
We found that gracy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.