jtlapp / node-cleanup

installs custom cleanup handlers that run on exiting node
MIT License
164 stars 10 forks source link

Use `process.once` to install signal handlers? #11

Open cpcallen opened 6 years ago

cpcallen commented 6 years ago

A small observation: if cleanup handers were installed using process.once instead of process.on it would be unnecessary to call uninstall before calling process.kill.

(Unfortunately uninstall is part of the public API of the package and might actually be useful to some dependents so probably can't be removed even though it would be otherwise unnecessary.)

sjungwirth commented 6 years ago

+1, I am also wondering if I have multiple async cleanup handlers that need to call uninstall, will they both run? Or do I need to warp the uninstall calls in a setImmediate to at least give everything the chance to run once.

jtlapp commented 6 years ago

I'll have a look at this over the weekend. Thanks for bringing this to my attention.