-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(run-engine): don't mislabel DB errors as UnclassifiableWaitpointId in completeWaitpoint #4259
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
Open
claude
wants to merge
8
commits into
main
Choose a base branch
from
fix/waitpoint-completion-db-error-mislabel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+106
−3
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
576941c
fix(run-engine): don't mislabel DB errors as UnclassifiableWaitpointI…
claude a743d33
test(run-engine): cover completeWaitpoint error passthrough vs classi…
claude 2f7fff6
chore: format completeWaitpoint test to satisfy oxfmt
claude 47efd09
Merge branch 'main' into fix/waitpoint-completion-db-error-mislabel
d-cs 73dd30d
Merge remote-tracking branch 'origin/main' into fix/waitpoint-complet…
claude 7fa1afc
Merge branch 'main' into fix/waitpoint-completion-db-error-mislabel
claude 4ccd956
fix(run-engine): match classification failures by error name as well …
matt-aitken d793ed5
Merge branch 'main' into fix/waitpoint-completion-db-error-mislabel
claude 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
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
internal-packages/run-engine/src/engine/tests/completeWaitpointErrorClassification.test.ts
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,82 @@ | ||
| // completeWaitpoint's store-selection guard must only turn a genuine id-classification | ||
| // failure into UnclassifiableWaitpointId. forWaitpointCompletion also probes the DB to | ||
| // resolve the owning store, so a transient database/infra error can surface from the same | ||
| // call — and those must bubble up UNCHANGED (keeping their original type, retryability, and | ||
| // error grouping) rather than being mislabelled as an unclassifiable id. | ||
| // | ||
| // This is a hermetic unit test: the error is thrown on the very first line of | ||
| // completeWaitpoint (runStore.forWaitpointCompletion), before any snapshot/enqueue work, | ||
| // so we can drive it with a minimal SystemResources and a fake runStore — no DB, no Redis. | ||
| import { UnclassifiableRunId } from "@trigger.dev/core/v3/isomorphic"; | ||
| import { expect } from "vitest"; | ||
| import { UnclassifiableWaitpointId } from "../errors.js"; | ||
| import type { SystemResources } from "../systems/systems.js"; | ||
| import { WaitpointSystem } from "../systems/waitpointSystem.js"; | ||
|
|
||
| function createWaitpointSystem(forWaitpointCompletion: () => Promise<never>) { | ||
| const runStore = { forWaitpointCompletion }; | ||
|
|
||
| const resources = { | ||
| runStore, | ||
| logger: { | ||
| error: vi.fn(), | ||
| warn: vi.fn(), | ||
| info: vi.fn(), | ||
| debug: vi.fn(), | ||
| }, | ||
| } as unknown as SystemResources; | ||
|
matt-aitken marked this conversation as resolved.
|
||
|
|
||
| return new WaitpointSystem({ | ||
| resources, | ||
| // Never reached on the store-resolution error path. | ||
| executionSnapshotSystem: {} as any, | ||
| enqueueSystem: {} as any, | ||
| }); | ||
| } | ||
|
|
||
| describe("completeWaitpoint store-resolution error classification", () => { | ||
| it("rethrows a transient database error unchanged (never wraps it as UnclassifiableWaitpointId)", async () => { | ||
| const dbError = new Error("Can't reach database server at db:5432"); | ||
| const waitpointSystem = createWaitpointSystem(() => Promise.reject(dbError)); | ||
|
|
||
| // The original error bubbles up as-is... | ||
| await expect(waitpointSystem.completeWaitpoint({ id: "waitpoint_transient" })).rejects.toBe( | ||
| dbError | ||
| ); | ||
| // ...and is NOT relabelled as a classification failure. | ||
| await expect( | ||
| waitpointSystem.completeWaitpoint({ id: "waitpoint_transient" }) | ||
| ).rejects.not.toBeInstanceOf(UnclassifiableWaitpointId); | ||
| }); | ||
|
|
||
| it("wraps a classification failure from a foreign module instance (matched by name, not instanceof)", async () => { | ||
| const waitpointId = "waitpoint_foreign_instance"; | ||
| const foreignError = new Error(`Unclassifiable run-ops id: ${waitpointId}`); | ||
| foreignError.name = "UnclassifiableRunId"; | ||
| const waitpointSystem = createWaitpointSystem(() => Promise.reject(foreignError)); | ||
|
|
||
| const caught = (await waitpointSystem | ||
| .completeWaitpoint({ id: waitpointId }) | ||
| .catch((error: unknown) => error)) as UnclassifiableWaitpointId; | ||
| expect(caught).toBeInstanceOf(UnclassifiableWaitpointId); | ||
| expect(caught.waitpointId).toBe(waitpointId); | ||
| expect(caught.cause).toBe(foreignError); | ||
| }); | ||
|
|
||
| it("wraps a genuine UnclassifiableRunId as UnclassifiableWaitpointId with the original as cause", async () => { | ||
| const waitpointId = "waitpoint_unclassifiable"; | ||
| const classificationError = new UnclassifiableRunId(waitpointId); | ||
| const waitpointSystem = createWaitpointSystem(() => Promise.reject(classificationError)); | ||
|
|
||
| await expect(waitpointSystem.completeWaitpoint({ id: waitpointId })).rejects.toBeInstanceOf( | ||
| UnclassifiableWaitpointId | ||
| ); | ||
|
|
||
| const caught = (await waitpointSystem | ||
| .completeWaitpoint({ id: waitpointId }) | ||
| .catch((error: unknown) => error)) as UnclassifiableWaitpointId; | ||
| expect(caught).toBeInstanceOf(UnclassifiableWaitpointId); | ||
| expect(caught.waitpointId).toBe(waitpointId); | ||
| expect(caught.cause).toBe(classificationError); | ||
| }); | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.