-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
process: refactor bootstrap of worker/main thread stdio, fatalException, and script evaluation #25199
Conversation
// this may indicate that node::FatalException should fix up the callback scope | ||
// before calling into process._fatalException, or this function should | ||
// take extra care of the async hooks before it schedules a setImmediate. | ||
function createFatalException() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun fact: you can fail the test on master with this diff
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 0f207ab660..a07b1e5657 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -645,7 +645,7 @@ function setupProcessFatal() {
emitAfter
} = NativeModule.require('internal/async_hooks');
- process._fatalException = (er) => {
+ process._fatalException = function foo(er) {
// It's possible that defaultTriggerAsyncId was set for a constructor
// call that threw and was never cleared. So clear it now.
clearDefaultTriggerAsyncId();
7173692
to
70245bc
Compare
This patch: - Moves `tryGetCwd`, `evalScript` and `fatalException` from `bootstrap/node.js` into `process/execution.js` so that they do have to be passed into the worker thread setup function, instead the worker code can require them when necessary. - Moves `setUncaughtExceptionCaptureCallback` and `hasUncaughtExceptionCaptureCallback` along with the two global state `exceptionHandlerState` and `shouldAbortOnUncaughtToggle` info `process.execution.js` as those are only used by the fatalException and these two accessors as one self-contained unit.
- Move `setupProcessStdio` which contains write access to the process object into `bootstrap/node.js` - Move `MessagePort`, `MessageChannel`, `ReadableWorkerStdio`, and `WritableWorkerStdio` into `internal/worker/io.js` - Move more worker-specific bootstrap code into `internal/process/worker_thread_only` from `setupChild` in `internal/worker.js`, and move the `process._fatalException` overwrite into `bootstrap/node.js` for clarity.
Move worker bootstrap code into worker_thread_only.js from internal/worker.js since they are only run once during bootstrap.
70245bc
to
1c52afd
Compare
Post force-push CI: https://ci.nodejs.org/job/node-test-pull-request/19781/ |
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/19786/ ✔️ |
Ping @addaleax @nodejs/process can I have some review please? |
Landed in da13c44...00babd3 |
This patch: - Moves `tryGetCwd`, `evalScript` and `fatalException` from `bootstrap/node.js` into `process/execution.js` so that they do have to be passed into the worker thread setup function, instead the worker code can require them when necessary. - Moves `setUncaughtExceptionCaptureCallback` and `hasUncaughtExceptionCaptureCallback` along with the two global state `exceptionHandlerState` and `shouldAbortOnUncaughtToggle` info `process.execution.js` as those are only used by the fatalException and these two accessors as one self-contained unit. PR-URL: #25199 Reviewed-By: James M Snell <[email protected]>
- Move `setupProcessStdio` which contains write access to the process object into `bootstrap/node.js` - Move `MessagePort`, `MessageChannel`, `ReadableWorkerStdio`, and `WritableWorkerStdio` into `internal/worker/io.js` - Move more worker-specific bootstrap code into `internal/process/worker_thread_only` from `setupChild` in `internal/worker.js`, and move the `process._fatalException` overwrite into `bootstrap/node.js` for clarity. PR-URL: #25199 Reviewed-By: James M Snell <[email protected]>
Move worker bootstrap code into worker_thread_only.js from internal/worker.js since they are only run once during bootstrap. PR-URL: #25199 Reviewed-By: James M Snell <[email protected]>
Should this be backported to |
This patch: - Moves `tryGetCwd`, `evalScript` and `fatalException` from `bootstrap/node.js` into `process/execution.js` so that they do have to be passed into the worker thread setup function, instead the worker code can require them when necessary. - Moves `setUncaughtExceptionCaptureCallback` and `hasUncaughtExceptionCaptureCallback` along with the two global state `exceptionHandlerState` and `shouldAbortOnUncaughtToggle` info `process.execution.js` as those are only used by the fatalException and these two accessors as one self-contained unit. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
- Move `setupProcessStdio` which contains write access to the process object into `bootstrap/node.js` - Move `MessagePort`, `MessageChannel`, `ReadableWorkerStdio`, and `WritableWorkerStdio` into `internal/worker/io.js` - Move more worker-specific bootstrap code into `internal/process/worker_thread_only` from `setupChild` in `internal/worker.js`, and move the `process._fatalException` overwrite into `bootstrap/node.js` for clarity. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
Move worker bootstrap code into worker_thread_only.js from internal/worker.js since they are only run once during bootstrap. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
Applies cleanly now, apart from the usual hickup in |
This patch: - Moves `tryGetCwd`, `evalScript` and `fatalException` from `bootstrap/node.js` into `process/execution.js` so that they do have to be passed into the worker thread setup function, instead the worker code can require them when necessary. - Moves `setUncaughtExceptionCaptureCallback` and `hasUncaughtExceptionCaptureCallback` along with the two global state `exceptionHandlerState` and `shouldAbortOnUncaughtToggle` info `process.execution.js` as those are only used by the fatalException and these two accessors as one self-contained unit. PR-URL: #25199 Reviewed-By: James M Snell <[email protected]>
- Move `setupProcessStdio` which contains write access to the process object into `bootstrap/node.js` - Move `MessagePort`, `MessageChannel`, `ReadableWorkerStdio`, and `WritableWorkerStdio` into `internal/worker/io.js` - Move more worker-specific bootstrap code into `internal/process/worker_thread_only` from `setupChild` in `internal/worker.js`, and move the `process._fatalException` overwrite into `bootstrap/node.js` for clarity. PR-URL: #25199 Reviewed-By: James M Snell <[email protected]>
Move worker bootstrap code into worker_thread_only.js from internal/worker.js since they are only run once during bootstrap. PR-URL: #25199 Reviewed-By: James M Snell <[email protected]>
This patch: - Moves `tryGetCwd`, `evalScript` and `fatalException` from `bootstrap/node.js` into `process/execution.js` so that they do have to be passed into the worker thread setup function, instead the worker code can require them when necessary. - Moves `setUncaughtExceptionCaptureCallback` and `hasUncaughtExceptionCaptureCallback` along with the two global state `exceptionHandlerState` and `shouldAbortOnUncaughtToggle` info `process.execution.js` as those are only used by the fatalException and these two accessors as one self-contained unit. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
- Move `setupProcessStdio` which contains write access to the process object into `bootstrap/node.js` - Move `MessagePort`, `MessageChannel`, `ReadableWorkerStdio`, and `WritableWorkerStdio` into `internal/worker/io.js` - Move more worker-specific bootstrap code into `internal/process/worker_thread_only` from `setupChild` in `internal/worker.js`, and move the `process._fatalException` overwrite into `bootstrap/node.js` for clarity. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
Move worker bootstrap code into worker_thread_only.js from internal/worker.js since they are only run once during bootstrap. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
This patch: - Moves `tryGetCwd`, `evalScript` and `fatalException` from `bootstrap/node.js` into `process/execution.js` so that they do have to be passed into the worker thread setup function, instead the worker code can require them when necessary. - Moves `setUncaughtExceptionCaptureCallback` and `hasUncaughtExceptionCaptureCallback` along with the two global state `exceptionHandlerState` and `shouldAbortOnUncaughtToggle` info `process.execution.js` as those are only used by the fatalException and these two accessors as one self-contained unit. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
- Move `setupProcessStdio` which contains write access to the process object into `bootstrap/node.js` - Move `MessagePort`, `MessageChannel`, `ReadableWorkerStdio`, and `WritableWorkerStdio` into `internal/worker/io.js` - Move more worker-specific bootstrap code into `internal/process/worker_thread_only` from `setupChild` in `internal/worker.js`, and move the `process._fatalException` overwrite into `bootstrap/node.js` for clarity. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
Move worker bootstrap code into worker_thread_only.js from internal/worker.js since they are only run once during bootstrap. PR-URL: nodejs#25199 Reviewed-By: James M Snell <[email protected]>
process: move eval and exception bootstrap ito process/execution.js
This patch:
tryGetCwd
,evalScript
andfatalException
frombootstrap/node.js
intoprocess/execution.js
so thatthey do have to be passed into the worker thread
setup function, instead the worker code can require them
when necessary.
setUncaughtExceptionCaptureCallback
andhasUncaughtExceptionCaptureCallback
along with the twoglobal state
exceptionHandlerState
andshouldAbortOnUncaughtToggle
infoprocess.execution.js
as those are only used by the fatalException and these
two accessors as one self-contained unit.
process: split worker IO into internal/worker/io.js
setupProcessStdio
which contains write access tothe process object into
bootstrap/node.js
MessagePort
,MessageChannel
,ReadableWorkerStdio
,and
WritableWorkerStdio
intointernal/worker/io.js
internal/process/worker_thread_only
fromsetupChild
in
internal/worker.js
, and move theprocess._fatalException
overwrite into
bootstrap/node.js
for clarity.process: move worker bootstrap code into worker_thread_only.js
Move worker bootstrap code into worker_thread_only.js from
internal/worker.js since they are only run once during bootstrap.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes