How to Better Implement This Code to Avoid no-process-exit
?
#14241
-
import config from "config";
import { MongoClient } from "mongodb";
const client = new MongoClient(config.mongodbURI, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
client.connect();
process.on("SIGINT", () => {
client.close().then(() => {
console.info("Closing Mongo client");
});
process.exit(0);
});
export default client; W/o going much beyond the issue regarding the linting, basically I am trying to keep my This code does the job. But, I don't care for just ignoring 🙈 linter issues unless I have clarity about what it's all about. After referencing the relevant document, I am definitely unsure. For one thing:
What error? I am doing Next, WTH is I tried like this one: For now, I am turning this to |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In this case it’s fine to turn off the rule. In general, process.exit() is best avoided because there’s no way to catch or respond to it. In the entry point to a CLI or service, it makes sense to use it. |
Beta Was this translation helpful? Give feedback.
In this case it’s fine to turn off the rule. In general, process.exit() is best avoided because there’s no way to catch or respond to it. In the entry point to a CLI or service, it makes sense to use it.