Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/world-local-run-failed-not-found.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/world-local": patch
---

Throw `WorkflowRunNotFoundError` when `run_failed` is recorded against a run that doesn't exist, matching the behaviour of `world-postgres` and `world-vercel`.
8 changes: 8 additions & 0 deletions packages/world-local/src/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ describe('Storage', () => {
expect(updated.error?.message).toBe('Something went wrong');
expect(updated.completedAt).toBeInstanceOf(Date);
});

it('should reject run_failed on non-existent run', async () => {
await expect(
updateRun(storage, 'wrun_nonexistent', 'run_failed', {
error: 'Something went wrong',
})
).rejects.toMatchObject({ name: 'WorkflowRunNotFoundError' });
});
});

describe('list', () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/world-local/src/storage/events-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
RunExpiredError,
RunNotSupportedError,
TooEarlyError,
WorkflowRunNotFoundError,
WorkflowWorldError,
} from '@workflow/errors';
import type {
Expand Down Expand Up @@ -226,6 +227,14 @@ export function createEventsStorage(
}
}

// run_failed on a non-existent run is rejected to match the
// postgres and vercel worlds, which both surface this as a
// WorkflowRunNotFoundError rather than silently persisting an
// event for a run that was never created.
if (data.eventType === 'run_failed' && !currentRun) {
throw new WorkflowRunNotFoundError(effectiveRunId);
}

// ============================================================
// VERSION COMPATIBILITY: Check run spec version
// ============================================================
Expand Down
Loading