What Node versions, OSs and CPU architectures are you building for?
node20-linux-x64
Describe the Bug
A GZip packaged program using a native node module and which exits with process.exit() does not remove the extracted external files from the /tmp directory. This is because the cleanup code is attached to the "beforeExit" event which is not called when process.exit is used or an exception is thrown. When attaching the cleanup code to "exit" instead then it works.
Check for /tmp/pkg-* files and notice that directory was not removed.
When not using process.exit() in the test program then the directory is removed. When using exit event instead of beforeExit event in bootstrap code then tmp directory is also correctly removed.
What version of pkg are you using?
5.11.5
What version of Node.js are you using?
20.12.0
What operating system are you using?
Debian 12
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node20-linux-x64
Describe the Bug
A GZip packaged program using a native node module and which exits with
process.exit()
does not remove the extracted external files from the /tmp directory. This is because the cleanup code is attached to the "beforeExit" event which is not called when process.exit is used or an exception is thrown. When attaching the cleanup code to "exit" instead then it works.See documentation of beforeExit and exit event.
Expected Behavior
Temporary files should always be removed when program exits.
To Reproduce
Create a
test.js
program using a native module like node-canvas (npm i canvas
). ExamplePackage the program with GZIP compression:
Run the program.
Check for
/tmp/pkg-*
files and notice that directory was not removed.When not using
process.exit()
in the test program then the directory is removed. When usingexit
event instead ofbeforeExit
event in bootstrap code then tmp directory is also correctly removed.