Commit c5b07d4e authored by Ben Noordhuis's avatar Ben Noordhuis
Browse files

lib: fix beforeExit not working with -e

Commit 93a44d52 ("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: https://github.com/nodejs/node/issues/8534
PR-URL: https://github.com/nodejs/node/pull/8821


Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
parent 8e54c968
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment