Skip to content

process.on("exit", fn) not being respected #7

Description

@cowboy

See sindresorhus/time-grunt#15.

Given the following code:

console.log("before");
process.on("exit", function() {
  console.log("on exit");
});
process.exit();
console.log("after");
  • In non-Windows Node.js, this properly logs before then on exit.
  • In Windows Node.js, this might log nothing, all three things, or some combination of them. Kinda random, depends on the shell, if output is piped or not, etc.
  • With require("exit")(); instead of process.exit(); only before is logged. on exit should be logged.

Take a look at this commit in the node-exit branch.

Granted, that code is currently failing... but if we can fix it, we might be able to allow @sindresorhus's plugin to continue working.

Possible solution: Set stream.write to a NOP function after the exit event has been called?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions