New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent releaseExit while exiting. #22
Conversation
The following roughly emulates what ember-cli is doing (2.13 canary only): ``` 'use strict'; // capture-exit-onExit.js var captureExit = require('.'); var RSVP = require('rsvp'); var interruptHandler; var promise = RSVP.Promise.resolve(). then(function() { console.log('capturing exit'); captureExit.captureExit(); captureExit.onExit(interruptHandler); }). then(function() { console.log('calling process.exit(1)'); process.exit(1); }). then(function() { console.log('releasing exit'); captureExit.releaseExit(); }). then(function() { console.log('calling process.exit()'); process.exit(); }); interruptHandler = function() { console.log('interrupt handler running'); return promise; }; ``` If we allow `.releaseExit` to run _during_ the `._flush` process, we can no longer ensure that the rest of the handlers are ran (if a `process.exit()` is ran after exit has been released).
347842d
to
69d6769
Compare
I have confirmed (via |
Should we prevent, or should we error. |
I'm 👍 on erroring here. |
Well, it is the default case for ember-cli right now (as explained in ember-cli/ember-cli#6779 (comment)). |
I am happy to change it around to be an error if |
yes that was the intention. And specifically, for capture-exit's own tests. |
Awesome, thanks for helping me understand the intent here. I've submitted ember-cli/ember-cli#6799 to remove the |
Refactor `capture-exit` usage to avoid releasing exit. Calling `exit.releaseExit()` (possibly _while exiting_) will lead to very difficult to track down bugs. We should capture exit very early in our processing, and simply not release. There are no downsides to this, and calling `captureExit.releaseExit()` during exit will soon throw an error (see ember-cli/capture-exit#22 (comment)). Fixes #6779
Closing, I'll open up a separate PR to make |
The following roughly emulates what ember-cli is doing (2.13 canary only):
If we allow
.releaseExit
to run during the._flush
process, we can no longer ensure that the rest of the handlers are ran (if aprocess.exit()
is ran after exit has been released).See longer explaination / code safari in ember-cli/ember-cli#6779 (comment).
This seems good to me, but I'd love feedback from @stefanpenner / @hjdivad / and others as there may be alternative conclusions to be made from the details in ember-cli/ember-cli#6779.