node-cleanup icon indicating copy to clipboard operation
node-cleanup copied to clipboard

Use `process.once` to install signal handlers?

Open cpcallen opened this issue 8 years ago • 2 comments

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.)

cpcallen avatar Oct 04 '17 10:10 cpcallen

+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.

sjungwirth avatar Oct 12 '17 16:10 sjungwirth

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

jtlapp avatar Oct 12 '17 17:10 jtlapp