Skip to content

lib: fix beforeExit not working with -e#8821

Merged
bnoordhuis merged 1 commit intonodejs:masterfrom
bnoordhuis:fix8534
Oct 24, 2016
Merged

lib: fix beforeExit not working with -e#8821
bnoordhuis merged 1 commit intonodejs:masterfrom
bnoordhuis:fix8534

Conversation

@bnoordhuis
Copy link
Member

Commit 93a44d5 ("src: fix deferred events not working with -e") defers
evaluation of the script to the next tick.

A side effect of that change is that 'beforeExit' listeners run before
the actual script. 'beforeExit' is emitted when the event loop is
empty but process.nextTick() does not ref the event loop.

Fix that by using setImmediate(). Because it is implemented in terms
of a uv_check_t handle, it interacts with the event loop properly.

Fixes: #8534

R=@Fishrock123

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

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. process Issues and PRs related to the process subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to listen to beforeExit in single-tick --eval

7 participants