diff --git a/.changeset/fix-recovery-queue-namespace.md b/.changeset/fix-recovery-queue-namespace.md new file mode 100644 index 0000000000..7ae929cc08 --- /dev/null +++ b/.changeset/fix-recovery-queue-namespace.md @@ -0,0 +1,7 @@ +--- +'@workflow/world': patch +'@workflow/world-local': patch +'@workflow/world-postgres': patch +--- + +Use the active queue namespace when re-enqueuing workflow runs during world startup recovery. diff --git a/.changeset/pre.json b/.changeset/pre.json index a5c97dbf39..724cf07ce4 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -164,6 +164,7 @@ "fix-observability-getworld-import", "fix-postgres-workflow-enums", "fix-provider-tool-identity", + "fix-recovery-queue-namespace", "fix-span-detail-flicker-state-machine", "fix-step-vs-wait-race-eager-wait", "fix-step-vs-wait-race", @@ -298,6 +299,8 @@ "remove-sdk-serde-exclusion", "remove-step-file-copy", "rename-domain-urls", + "rename-set-attributes-world", + "rename-set-attributes", "repair-ui-message-stream-framing", "replay-consumed-event-clock", "replay-divergence-redelivery", diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index cc51e68f72..58ea63c150 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,14 @@ # @workflow/astro +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies []: + - @workflow/builders@5.0.0-beta.31 + - @workflow/rollup@5.0.0-beta.31 + - @workflow/vite@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 5f4577a4f6..405ff1e0e1 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/astro", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Astro integration for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/builders/CHANGELOG.md b/packages/builders/CHANGELOG.md index cdf69dc891..6dfbcb13b8 100644 --- a/packages/builders/CHANGELOG.md +++ b/packages/builders/CHANGELOG.md @@ -1,5 +1,15 @@ # @workflow/builders +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world-local@5.0.0-beta.27 + - @workflow/core@5.0.0-beta.31 + - @workflow/errors@5.0.0-beta.10 + - @workflow/world-vercel@5.0.0-beta.27 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/builders/package.json b/packages/builders/package.json index c18cd64678..acd294509d 100644 --- a/packages/builders/package.json +++ b/packages/builders/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/builders", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Shared builder infrastructure for Workflow SDK", "type": "module", "main": "./dist/index.js", diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 4c7702d067..04bdda0cd1 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,18 @@ # @workflow/cli +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/world-local@5.0.0-beta.27 + - @workflow/core@5.0.0-beta.31 + - @workflow/errors@5.0.0-beta.10 + - @workflow/web@5.0.0-beta.31 + - @workflow/world-vercel@5.0.0-beta.27 + - @workflow/builders@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index f5bd6bebed..9397ab2d30 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/cli", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Command-line interface for Workflow SDK", "type": "module", "bin": { diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 0443051a6c..9da7488700 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,19 @@ # @workflow/core +## 5.0.0-beta.31 + +### Minor Changes + +- [#2882](https://github.com/vercel/workflow/pull/2882) [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2) Thanks [@VaguelySerious](https://github.com/VaguelySerious)! - Rename `experimental_setAttributes` to `setAttributes` — the attributes feature is no longer experimental. The old name remains available as a deprecated alias. + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/world-local@5.0.0-beta.27 + - @workflow/errors@5.0.0-beta.10 + - @workflow/world-vercel@5.0.0-beta.27 + ## 5.0.0-beta.30 ### Minor Changes diff --git a/packages/core/package.json b/packages/core/package.json index c6cd97d91d..c4587666b0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/core", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Core runtime and engine for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/nest/CHANGELOG.md b/packages/nest/CHANGELOG.md index f916c35f2e..3bdbde23ab 100644 --- a/packages/nest/CHANGELOG.md +++ b/packages/nest/CHANGELOG.md @@ -1,5 +1,12 @@ # @workflow/nest +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies []: + - @workflow/builders@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/nest/package.json b/packages/nest/package.json index 9590baa69f..1618cdc394 100644 --- a/packages/nest/package.json +++ b/packages/nest/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/nest", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "NestJS integration for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/next/CHANGELOG.md b/packages/next/CHANGELOG.md index c35971a1c8..5430eee124 100644 --- a/packages/next/CHANGELOG.md +++ b/packages/next/CHANGELOG.md @@ -1,5 +1,13 @@ # @workflow/next +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/core@5.0.0-beta.31 + - @workflow/builders@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/next/package.json b/packages/next/package.json index 08505fbeee..81dc542521 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/next", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Next.js integration for Workflow SDK", "type": "commonjs", "main": "dist/index.js", diff --git a/packages/nitro/CHANGELOG.md b/packages/nitro/CHANGELOG.md index 8cf67f5031..1dbe7c5ec0 100644 --- a/packages/nitro/CHANGELOG.md +++ b/packages/nitro/CHANGELOG.md @@ -1,5 +1,16 @@ # @workflow/nitro +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/core@5.0.0-beta.31 + - @workflow/web@5.0.0-beta.31 + - @workflow/builders@5.0.0-beta.31 + - @workflow/rollup@5.0.0-beta.31 + - @workflow/vite@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/nitro/package.json b/packages/nitro/package.json index 4b409eefb5..ffea2d9a96 100644 --- a/packages/nitro/package.json +++ b/packages/nitro/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/nitro", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Nitro integration for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/nuxt/CHANGELOG.md b/packages/nuxt/CHANGELOG.md index e59b1f1b70..03bcc32ae9 100644 --- a/packages/nuxt/CHANGELOG.md +++ b/packages/nuxt/CHANGELOG.md @@ -1,5 +1,13 @@ # @workflow/nuxt +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies []: + - @workflow/builders@5.0.0-beta.31 + - @workflow/nitro@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 762628a424..2b22a564c8 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/nuxt", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Nuxt integration for Workflow SDK", "license": "Apache-2.0", "type": "module", diff --git a/packages/rollup/CHANGELOG.md b/packages/rollup/CHANGELOG.md index 4e5e09caba..33a3f59249 100644 --- a/packages/rollup/CHANGELOG.md +++ b/packages/rollup/CHANGELOG.md @@ -1,5 +1,12 @@ # @workflow/rollup +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies []: + - @workflow/builders@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/rollup/package.json b/packages/rollup/package.json index cc99118b09..8f3818e1d7 100644 --- a/packages/rollup/package.json +++ b/packages/rollup/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/rollup", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Rollup plugin for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/sveltekit/CHANGELOG.md b/packages/sveltekit/CHANGELOG.md index d19edc83ff..5b8d322026 100644 --- a/packages/sveltekit/CHANGELOG.md +++ b/packages/sveltekit/CHANGELOG.md @@ -1,5 +1,14 @@ # @workflow/sveltekit +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies []: + - @workflow/builders@5.0.0-beta.31 + - @workflow/rollup@5.0.0-beta.31 + - @workflow/vite@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index 3625081ad4..56d52fa911 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/sveltekit", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "SvelteKit integration for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/vite/CHANGELOG.md b/packages/vite/CHANGELOG.md index 4998d991e1..1d9f448f9a 100644 --- a/packages/vite/CHANGELOG.md +++ b/packages/vite/CHANGELOG.md @@ -1,5 +1,12 @@ # @workflow/vite +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies []: + - @workflow/builders@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/vite/package.json b/packages/vite/package.json index a7ff44c9c7..b415b8cb1a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -1,7 +1,7 @@ { "name": "@workflow/vite", "description": "Vite plugin for Workflow SDK", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "type": "module", "main": "dist/index.js", "files": [ diff --git a/packages/vitest/CHANGELOG.md b/packages/vitest/CHANGELOG.md index d805443e4c..f11dd22b3b 100644 --- a/packages/vitest/CHANGELOG.md +++ b/packages/vitest/CHANGELOG.md @@ -1,5 +1,16 @@ # @workflow/vitest +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/world-local@5.0.0-beta.27 + - @workflow/core@5.0.0-beta.31 + - @workflow/builders@5.0.0-beta.31 + - @workflow/rollup@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/vitest/package.json b/packages/vitest/package.json index 0479893798..e3ba954e37 100644 --- a/packages/vitest/package.json +++ b/packages/vitest/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/vitest", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Vitest plugin for testing Workflow SDK workflows", "type": "module", "main": "./dist/index.js", diff --git a/packages/web-shared/CHANGELOG.md b/packages/web-shared/CHANGELOG.md index 6fc627dc8c..6548556888 100644 --- a/packages/web-shared/CHANGELOG.md +++ b/packages/web-shared/CHANGELOG.md @@ -1,5 +1,13 @@ # @workflow/web-shared +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/core@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/web-shared/package.json b/packages/web-shared/package.json index 7c4c2ff7eb..52f9e2cb9f 100644 --- a/packages/web-shared/package.json +++ b/packages/web-shared/package.json @@ -1,7 +1,7 @@ { "name": "@workflow/web-shared", "description": "Shared components for Workflow Observability UI", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "private": false, "files": [ "dist", diff --git a/packages/web/CHANGELOG.md b/packages/web/CHANGELOG.md index dfd8d647be..14482a8723 100644 --- a/packages/web/CHANGELOG.md +++ b/packages/web/CHANGELOG.md @@ -1,5 +1,12 @@ # @workflow/web +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8)]: + - @workflow/world-local@5.0.0-beta.27 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/web/package.json b/packages/web/package.json index fa87d84c90..c6f3eac9fb 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,7 +1,7 @@ { "name": "@workflow/web", "description": "Workflow Observability UI", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "type": "module", "private": false, "files": [ diff --git a/packages/workflow/CHANGELOG.md b/packages/workflow/CHANGELOG.md index 3660727a2c..1ab812fb8c 100644 --- a/packages/workflow/CHANGELOG.md +++ b/packages/workflow/CHANGELOG.md @@ -1,5 +1,26 @@ # workflow +## 5.0.0-beta.31 + +### Minor Changes + +- [#2882](https://github.com/vercel/workflow/pull/2882) [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2) Thanks [@VaguelySerious](https://github.com/VaguelySerious)! - Rename `experimental_setAttributes` to `setAttributes` — the attributes feature is no longer experimental. The old name remains available as a deprecated alias. + +### Patch Changes + +- Updated dependencies [[`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/core@5.0.0-beta.31 + - @workflow/cli@5.0.0-beta.31 + - @workflow/errors@5.0.0-beta.10 + - @workflow/next@5.0.0-beta.31 + - @workflow/nitro@5.0.0-beta.31 + - @workflow/typescript-plugin@5.0.0-beta.5 + - @workflow/astro@5.0.0-beta.31 + - @workflow/nest@5.0.0-beta.31 + - @workflow/nuxt@5.0.0-beta.31 + - @workflow/rollup@5.0.0-beta.31 + - @workflow/sveltekit@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/workflow/package.json b/packages/workflow/package.json index acd8fec204..ff312b2da1 100644 --- a/packages/workflow/package.json +++ b/packages/workflow/package.json @@ -1,6 +1,6 @@ { "name": "workflow", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Workflow SDK - Build durable, resilient, and observable workflows", "main": "dist/typescript-plugin.cjs", "type": "module", diff --git a/packages/world-local/CHANGELOG.md b/packages/world-local/CHANGELOG.md index 77bea42b30..d30379fb02 100644 --- a/packages/world-local/CHANGELOG.md +++ b/packages/world-local/CHANGELOG.md @@ -1,5 +1,15 @@ # @workflow/world-local +## 5.0.0-beta.27 + +### Patch Changes + +- [#2888](https://github.com/vercel/workflow/pull/2888) [`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8) Thanks [@ctgowrie](https://github.com/ctgowrie)! - Use the active queue namespace when re-enqueuing workflow runs during world startup recovery. + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/errors@5.0.0-beta.10 + ## 5.0.0-beta.26 ### Patch Changes diff --git a/packages/world-local/package.json b/packages/world-local/package.json index 53c2678582..1a08ec9b50 100644 --- a/packages/world-local/package.json +++ b/packages/world-local/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/world-local", - "version": "5.0.0-beta.26", + "version": "5.0.0-beta.27", "description": "Local development World implementation for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/world-local/src/reenqueue.test.ts b/packages/world-local/src/reenqueue.test.ts index ac38bfa9e9..97eeea00fa 100644 --- a/packages/world-local/src/reenqueue.test.ts +++ b/packages/world-local/src/reenqueue.test.ts @@ -1,6 +1,7 @@ import { rm } from 'node:fs/promises'; import os from 'node:os'; import path from 'node:path'; +import { WorkflowInvokePayloadSchema } from '@workflow/world'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { createWorld } from './index.js'; import { createRun, updateRun } from './test-helpers.js'; @@ -14,10 +15,12 @@ describe('re-enqueue active runs on start', () => { let dataDir: string; beforeEach(() => { + vi.stubEnv('WORKFLOW_QUEUE_NAMESPACE', undefined); dataDir = path.join(os.tmpdir(), `wf-reenqueue-${Date.now()}`); }); afterEach(async () => { + vi.unstubAllEnvs(); await rm(dataDir, { recursive: true, force: true }); }); @@ -86,6 +89,49 @@ describe('re-enqueue active runs on start', () => { await world2.close(); }); + it('re-enqueues runs to the active queue namespace', async () => { + vi.stubEnv('WORKFLOW_QUEUE_NAMESPACE', 'custom'); + + const world1 = createWorld({ dataDir }); + await world1.start(); + + const pendingRun = await createRun(world1, { + deploymentId: 'dpl_1', + workflowName: 'myWorkflow', + input: new Uint8Array([1]), + }); + + await world1.close(); + + const world2 = createWorld({ dataDir }); + const namespacedRunIds: string[] = []; + const unnamespacedRunIds: string[] = []; + const namespacedHandler = world2.createQueueHandler( + '__custom_wkf_workflow_', + async (message) => { + const body = WorkflowInvokePayloadSchema.parse(message); + namespacedRunIds.push(body.runId); + } + ); + world2.registerHandler('__custom_wkf_workflow_', namespacedHandler); + // Capture an incorrectly reconstructed queue without allowing it to enter + // the local queue's retry loop. + world2.registerHandler('__wkf_workflow_', async (req) => { + const body = await req.json(); + unnamespacedRunIds.push(body.runId); + return Response.json({ ok: true }); + }); + + await world2.start(); + + await vi.waitFor(() => { + expect(namespacedRunIds).toEqual([pendingRun.runId]); + }); + expect(unnamespacedRunIds).toHaveLength(0); + + await world2.close(); + }); + it('does nothing when there are no active runs', async () => { // Create a world with only completed runs const world1 = createWorld({ dataDir }); diff --git a/packages/world-postgres/CHANGELOG.md b/packages/world-postgres/CHANGELOG.md index d62ffdf433..786e1443d3 100644 --- a/packages/world-postgres/CHANGELOG.md +++ b/packages/world-postgres/CHANGELOG.md @@ -1,5 +1,16 @@ # @workflow/world-postgres +## 5.0.0-beta.25 + +### Patch Changes + +- [#2888](https://github.com/vercel/workflow/pull/2888) [`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8) Thanks [@ctgowrie](https://github.com/ctgowrie)! - Use the active queue namespace when re-enqueuing workflow runs during world startup recovery. + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/world-local@5.0.0-beta.27 + - @workflow/errors@5.0.0-beta.10 + ## 5.0.0-beta.24 ### Patch Changes diff --git a/packages/world-postgres/package.json b/packages/world-postgres/package.json index 34b24a985b..e067700dc1 100644 --- a/packages/world-postgres/package.json +++ b/packages/world-postgres/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/world-postgres", - "version": "5.0.0-beta.24", + "version": "5.0.0-beta.25", "description": "A reference World implementation based on PostgreSQL", "type": "module", "main": "dist/index.js", diff --git a/packages/world-postgres/src/index.ts b/packages/world-postgres/src/index.ts index 95c66e522c..d9ab8280f3 100644 --- a/packages/world-postgres/src/index.ts +++ b/packages/world-postgres/src/index.ts @@ -70,7 +70,12 @@ export function createWorld( }), async start() { await queue.start(); - await reenqueueActiveRuns(storage.runs, queue.queue, 'world-postgres'); + await reenqueueActiveRuns( + storage.runs, + queue.queue, + 'world-postgres', + config.namespace + ); }, async close() { await streamer.close(); diff --git a/packages/world-testing/CHANGELOG.md b/packages/world-testing/CHANGELOG.md index d307f73089..753e268fe8 100644 --- a/packages/world-testing/CHANGELOG.md +++ b/packages/world-testing/CHANGELOG.md @@ -1,5 +1,16 @@ # @workflow/world-testing +## 5.0.0-beta.31 + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/world-local@5.0.0-beta.27 + - @workflow/core@5.0.0-beta.31 + - workflow@5.0.0-beta.31 + - @workflow/cli@5.0.0-beta.31 + ## 5.0.0-beta.30 ### Patch Changes diff --git a/packages/world-testing/package.json b/packages/world-testing/package.json index c36749449c..2318737035 100644 --- a/packages/world-testing/package.json +++ b/packages/world-testing/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/world-testing", - "version": "5.0.0-beta.30", + "version": "5.0.0-beta.31", "description": "Testing utilities and World implementation for Workflow SDK", "main": "dist/src/index.mjs", "files": [ diff --git a/packages/world-vercel/CHANGELOG.md b/packages/world-vercel/CHANGELOG.md index 19207dc5f3..bb7eb1bdb5 100644 --- a/packages/world-vercel/CHANGELOG.md +++ b/packages/world-vercel/CHANGELOG.md @@ -1,5 +1,13 @@ # @workflow/world-vercel +## 5.0.0-beta.27 + +### Patch Changes + +- Updated dependencies [[`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8), [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2)]: + - @workflow/world@5.0.0-beta.19 + - @workflow/errors@5.0.0-beta.10 + ## 5.0.0-beta.26 ### Minor Changes diff --git a/packages/world-vercel/package.json b/packages/world-vercel/package.json index a928928053..9e289e131f 100644 --- a/packages/world-vercel/package.json +++ b/packages/world-vercel/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/world-vercel", - "version": "5.0.0-beta.26", + "version": "5.0.0-beta.27", "description": "Vercel platform World implementation for Workflow SDK", "type": "module", "main": "dist/index.js", diff --git a/packages/world/CHANGELOG.md b/packages/world/CHANGELOG.md index f7305592e7..dab61898a7 100644 --- a/packages/world/CHANGELOG.md +++ b/packages/world/CHANGELOG.md @@ -1,5 +1,13 @@ # @workflow/world +## 5.0.0-beta.19 + +### Patch Changes + +- [#2888](https://github.com/vercel/workflow/pull/2888) [`7a1ea5a`](https://github.com/vercel/workflow/commit/7a1ea5a45afd07601934a2f3ff1d1044f3bd9db8) Thanks [@ctgowrie](https://github.com/ctgowrie)! - Use the active queue namespace when re-enqueuing workflow runs during world startup recovery. + +- [#2882](https://github.com/vercel/workflow/pull/2882) [`0b956f6`](https://github.com/vercel/workflow/commit/0b956f65cb0ab30501c72e934fc8d4352c4c3ea2) Thanks [@VaguelySerious](https://github.com/VaguelySerious)! - Update doc comments to reference `setAttributes` (renamed from `experimental_setAttributes`). + ## 5.0.0-beta.18 ### Minor Changes diff --git a/packages/world/package.json b/packages/world/package.json index 46b4929d9e..e8c1d24f3f 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -1,6 +1,6 @@ { "name": "@workflow/world", - "version": "5.0.0-beta.18", + "version": "5.0.0-beta.19", "description": "The Workflows World interface", "type": "module", "main": "dist/index.js", diff --git a/packages/world/src/recovery.test.ts b/packages/world/src/recovery.test.ts new file mode 100644 index 0000000000..64bf9d961b --- /dev/null +++ b/packages/world/src/recovery.test.ts @@ -0,0 +1,51 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; +import type { Storage } from './interfaces.js'; +import type { Queue } from './queue.js'; +import { reenqueueActiveRuns } from './recovery.js'; + +function createRuns(): Storage['runs'] { + return { + list: vi.fn(async ({ status }) => ({ + data: + status === 'pending' + ? [ + { + runId: 'wrun_AAA', + workflowName: 'myWorkflow', + status, + }, + ] + : [], + hasMore: false, + cursor: null, + })), + } as unknown as Storage['runs']; +} + +describe('reenqueueActiveRuns', () => { + afterEach(() => { + vi.unstubAllEnvs(); + }); + + it('uses WORKFLOW_QUEUE_NAMESPACE for recovered runs', async () => { + vi.stubEnv('WORKFLOW_QUEUE_NAMESPACE', 'custom'); + const enqueue = vi.fn(); + + await reenqueueActiveRuns(createRuns(), enqueue, 'test'); + + expect(enqueue).toHaveBeenCalledWith('__custom_wkf_workflow_myWorkflow', { + runId: 'wrun_AAA', + }); + }); + + it('prefers an explicit namespace over WORKFLOW_QUEUE_NAMESPACE', async () => { + vi.stubEnv('WORKFLOW_QUEUE_NAMESPACE', 'environment'); + const enqueue = vi.fn(); + + await reenqueueActiveRuns(createRuns(), enqueue, 'test', 'explicit'); + + expect(enqueue).toHaveBeenCalledWith('__explicit_wkf_workflow_myWorkflow', { + runId: 'wrun_AAA', + }); + }); +}); diff --git a/packages/world/src/recovery.ts b/packages/world/src/recovery.ts index d20cfa33c1..ec13face94 100644 --- a/packages/world/src/recovery.ts +++ b/packages/world/src/recovery.ts @@ -1,6 +1,10 @@ -import type { Queue } from './queue.js'; import type { Storage } from './interfaces.js'; import type { ValidQueueName } from './queue.js'; +import { + getQueueTopicPrefix, + type Queue, + resolveQueueNamespace, +} from './queue.js'; /** * Re-enqueue all active (pending/running) workflow runs so they resume @@ -10,12 +14,18 @@ import type { ValidQueueName } from './queue.js'; * @param runs - Storage runs interface for listing active runs * @param enqueue - Queue's enqueue method * @param label - Log prefix for identifying the world implementation (e.g. "world-local") + * @param namespace - Optional queue namespace. Defaults to WORKFLOW_QUEUE_NAMESPACE. */ export async function reenqueueActiveRuns( runs: Storage['runs'], enqueue: Queue['queue'], - label: string + label: string, + namespace?: string ): Promise { + const workflowQueuePrefix = getQueueTopicPrefix( + 'workflow', + resolveQueueNamespace(namespace) + ); let reenqueued = 0; for (const status of ['pending', 'running'] as const) { let cursor: string | undefined; @@ -28,7 +38,7 @@ export async function reenqueueActiveRuns( }); for (const run of page.data) { try { - const queueName: ValidQueueName = `__wkf_workflow_${run.workflowName}`; + const queueName: ValidQueueName = `${workflowQueuePrefix}${run.workflowName}`; await enqueue(queueName, { runId: run.runId }); reenqueued++; } catch (err) {