jprichardson / jprichardson/node-death
Node-Death SIGINT working fine on windows, but not gracefully shutting down services on Linux or MacOS platform
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 182
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Hi Team,
Issue:
I'm using node-death in my project. Node-Death is working fine when I'm running my application in Windows platform. On 'SIGINT' (ctrl+c) its gracefully shutting down the open connections made in my application.
But when I issue 'SIGINT' signal from either MacOS or Linux platforms it, immediately shuts down the application without graceful shutdown of open connections. I have also used 'process.stdin.resume()' to prevent immediate shutdown, but still doesn't work.
Please find below my code:
import ON_DEATH from 'death';
import mongoose from './db.config';
import redisClient from './redis.config';
import { logger } from './pino.config';
const logError = (from, code, error) => {
logger.error({ from, code, error });
};
const logInfo = connectionName => (logger.info({ message: `Connection with ${connectionName} shutdown gracefully!!!` }));
const shutdownRedis = () => redisClient.quit();
const shutdownMongoose = () => mongoose.connection.close(false);
// Begin reading from stdin so the process does not exit.
process.stdin.resume();
const onDeathCallback = async () => {
try {
await shutdownRedis();
logInfo('Redis');
await shutdownMongoose();
logInfo('Mongo');
} catch (err) {
logError('death.config.onDeathCallback', 'ERR_GRACEFUL_CONN_SHUTDOWN', err);
}
};
ON_DEATH(onDeathCallback);
Expected Output:
Connection with Redis shutdown gracefully!!!
Connection with Mongo shutdown gracefully!!!
Actual Output:
No output as it doesn't execute the callback
Please kindly let me know if I'm doing anything wrong with the configurations.
Looking forward to your help/reply on the above issue.
Thanks & Regards,
Siddharth
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Start by reproducing the provided node-death example with SIGINT on Linux and macOS, then inspect the package's signal-handling entry point and compare its behavior with Windows. Done means the callback runs and both Redis and Mongo shutdown messages appear on the affected platforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100