Repository navigation
Conversation
…tive parseWorkflowCode evaluates the bundle in an unconfigured vm context so that debuggers resolve breakpoints reliably, and ignores the TypeError this throws. Under --abort-on-uncaught-exception V8 treats that error as uncaught, because it does not see the handler outside of the vm context, and aborts the process before the Worker starts. Skip the preload unless an inspector is active. It only benefits a debugger. Fixes temporalio#1578
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
parseWorkflowCodenow preloads the Workflow bundle only when an inspector is active (inspector.url() !== undefined). Without an inspector it skips the preload.A regression test in
test-bundler.local.tsrunsparseWorkflowCodein a child process started with--abort-on-uncaught-exceptionand expects exit status 0. A changelog fragment is added underfixed.Why?
The preload evaluates the bundle in an empty vm context so that debuggers resolve breakpoints reliably. That evaluation throws a
TypeError(globalThis.__webpack_module_cache__is undefined), which the surroundingtry/catchignores. Under--abort-on-uncaught-exceptionV8 does not see a handler across the vm context boundary, so it aborts the process before the Worker starts.The issue suggests making the preload conditional on the presence of a debugger, since it is expensive and only useful to one. This PR does that and nothing more.
flowchart TD A[Worker parses the Workflow bundle] --> B{Node runs with abort on uncaught exception} B -->|Before| C[Preload throws in vm context and V8 aborts] B -->|After| D[No inspector so no preload and Worker starts]Narrated and captioned recording, before then after:
evidence.mp4
Commands shown in the recording, with the fix reverted and then restored (output trimmed to the test result):
git checkout upstream/main -- packages/worker/src/worker.ts pnpm -s -F @temporalio/worker run build pnpm -s ava lib/test-bundler.local.js -m "*abort*"git checkout HEAD -- packages/worker/src/worker.ts pnpm -s -F @temporalio/worker run build pnpm -s ava lib/test-bundler.local.js -m "*abort*"Checklist
Closes [Bug] Worker fails to start if Node option --abort-on-uncaught-exception is set #1578
How was this tested:
main(child killed bySIGTRAP) and passes with the change, as shown above.pnpm ava lib/test-bundler.local.js lib/test-worker-lazy-bundler.js: 16 tests passed.--inspect=0the preload still runs once; without an inspector it does not run.tsc --buildfor the worker and test packages,oxlint,oxfmt --check,pnpm changelog:checkandcommitlintpass.Two things reviewers should know:
SIGUSR1) no longer gets the preload. Starting Node with--inspectkeeps today's behavior.--abort-on-uncaught-exceptionstarts and completes Workflows against a local dev server, but the process still aborts atworker.shutdown()withUncaught ShutdownError: Worker has been shutdown, raised from the native bridge. That is a separate abort site and is not addressed here. An inspector combined with this flag also still aborts in the preload. Say if you would rather keep the issue open for those.Any docs updates needed?
No.
AI assistance (Claude Code) was used to prepare this change.
🤖 Generated with Claude Code