-
Notifications
You must be signed in to change notification settings - Fork 15
Fix worker crash caused by async promise antipattern and event ordering #1311
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
Merged
josephjclark
merged 12 commits into
release/next
from
fix/worker-crash-async-promise-antipattern
Mar 17, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4e9bfb1
fix(ws-worker): remove async promise antipattern in run-log.ts
stuartc 67c48d6
fix(ws-worker): remove async promise antipattern in try-with-backoff.ts
stuartc 8de1402
fix(ws-worker): remove async promise antipattern in destroy.ts
stuartc 3aab9a0
fix(engine-multi): emit compilation log before workflow-error
stuartc 2693342
chore: add changesets for worker crash fixes
stuartc 77f59a5
chore: exclude engine-multi tmp from pnpm workspace
stuartc b5ea537
remove duplicate log, tidy types
josephjclark 6cb528f
update changelogs
josephjclark 2df753e
tidy test
josephjclark 56ac483
revert diff on destroy
josephjclark 0a0ba8a
keep destroy change after all and fix test
josephjclark 543848d
relax runtime test
josephjclark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@openfn/ws-worker': patch | ||
| --- | ||
|
|
||
| Fix an issue where unhandled errors could trigger a worker crash after a compilation error. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@openfn/engine-multi': patch | ||
| --- | ||
|
|
||
| Emit compilation failure log before workflow-error event. Previously the error | ||
| event arrived first, causing the worker to tear down the channel before the | ||
| log could be delivered. |
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,15 +57,12 @@ export default async function onRunLog( | |
| }; | ||
| return sendEvent<RunLogPayload>(context, RUN_LOG_BATCH, payload); | ||
| } else { | ||
| return new Promise<void>(async (resolve) => { | ||
| for (const log of logs) { | ||
| const payload = { | ||
| run_id: `${state.plan.id}`, | ||
| ...log, | ||
| } as LegacyRunLogPayload; | ||
| await sendEvent<LegacyRunLogPayload>(context, RUN_LOG, payload); | ||
| } | ||
| resolve(); | ||
| }); | ||
| for (const log of logs) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, this absolutely makes sense 👍 |
||
| const payload = { | ||
| run_id: `${state.plan.id}`, | ||
| ...log, | ||
| } as LegacyRunLogPayload; | ||
| await sendEvent<LegacyRunLogPayload>(context, RUN_LOG, payload); | ||
| } | ||
| } | ||
| } | ||
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
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
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
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
Oops, something went wrong.
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.
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.
I've just pushed this unrelated fix, which will not include a changeset
The test is looking for a number like
1.2mbin the outputBut by chance in CI it just output
19mb, which failed the test.I really don't care if it's a decimal or node. Just a number followed by mb is fine.