diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2016-09-28 12:01:48 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2016-10-24 23:12:47 +0200 |
commit | c5b07d4ec6de2cb362b887499e44655eaeb26cba (patch) | |
tree | 96943343dba9866287cfa2caf4d129afc384dbb2 /lib | |
parent | 8e54c968e692fb55e2ddf0899172785c7b7b5812 (diff) | |
download | android-node-v8-c5b07d4ec6de2cb362b887499e44655eaeb26cba.tar.gz android-node-v8-c5b07d4ec6de2cb362b887499e44655eaeb26cba.tar.bz2 android-node-v8-c5b07d4ec6de2cb362b887499e44655eaeb26cba.zip |
lib: fix beforeExit not working with -e
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: https://github.com/nodejs/node/issues/8534
PR-URL: https://github.com/nodejs/node/pull/8821
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/bootstrap_node.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 8b8d066ab0..8db79aa33f 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -341,7 +341,7 @@ // Defer evaluation for a tick. This is a workaround for deferred // events not firing when evaluating scripts from the command line, // see https://github.com/nodejs/node/issues/1600. - process.nextTick(function() { + setImmediate(function() { const result = module._compile(script, `${name}-wrapper`); if (process._print_eval) console.log(result); }); |