-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Impossible to listen to beforeExit in single-tick --eval #8534
Labels
Comments
Fishrock123
added
confirmed-bug
Issues with confirmed bugs.
process
Issues and PRs related to the process subsystem.
labels
Sep 14, 2016
ping @bnoordhuis and @trevnorris |
bnoordhuis
added a commit
to bnoordhuis/io.js
that referenced
this issue
Oct 24, 2016
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: nodejs#8534 PR-URL: nodejs#8821 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
evanlucas
pushed a commit
that referenced
this issue
Nov 2, 2016
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 PR-URL: #8821 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins
pushed a commit
that referenced
this issue
Nov 18, 2016
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 PR-URL: #8821 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2 tasks
MylesBorins
pushed a commit
to MylesBorins/node
that referenced
this issue
Nov 18, 2016
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. Ref: nodejs#9680 Fixes: nodejs#8534 PR-URL: nodejs#8821 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins
pushed a commit
that referenced
this issue
Nov 19, 2016
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 PR-URL: #8821 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The following exits without printing:
node -e "process.on('beforeExit', () => process._rawDebug('hi'))"
However, this does print:
node -e "process.on('beforeExit', () => process._rawDebug('hi')); setImmediate(()=>{})"
I did some debugging and using this patch I get the following output:
That is,
beforeExit
fires before the listener is attached.Turns out that
at evalScript (bootstrap_node.js:344:13)
leads to this code and comment inevalScript()
:That comment leads back to #1600 -
net.listen does not emit 'listening' event when in --eval mode
.That was fixed in 93a44d5 by @bnoordhuis and reviewed by @trevnorris resulting in this code in
evalScript()
.Not sure how to fix this right now, but it seems like a deeper bug somewhere relating to startup and nextTick.
Refs: #1793 & #1600 & also the older nodejs/node-v0.x-archive#14168
Edit: found by @cxreg
The text was updated successfully, but these errors were encountered: