workflow 4.8.15 → 4.8.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,7 @@ Additionally, the runtime previously called `world.runs.get(runId)` before `run_
19
19
  - If `events.create` errors with **429 or 5xx**, we log a warning saying that run creation failed but the run was accepted — creation will be re-tried async by the runtime when it processes the queue message. The returned `Run` instance is marked with `resilientStart = true`.
20
20
  - If `events.create` errors with **409** (EntityConflictError), the run already exists (e.g., the queue handler's resilient start path created it first due to a cold-start race). This is treated as success.
21
21
  - If `world.queue` fails, we still throw — the run truly failed and was not enqueued.
22
+ - `run_created` has usually committed by then, so a thrown queue failure leaves a run that exists and never runs (and a caller that retries starts a second one). World queues should therefore retry a transient send failure themselves before it reaches `start()`: world-vercel re-sends after a transport failure, its request deadline, a 5xx or a short 429, up to 3 attempts (see `packages/world-vercel/src/queue-send-retry.ts`). Every re-send is safe: keyed messages are deduplicated by the queue, and a duplicate orchestrator message is a spare wake.
22
23
  - The queue invocation now receives all the run inputs (`input`, `deploymentId`, `workflowName`, `specVersion`, `executionContext`) via `runInput` so the runtime can create the run later if needed.
23
24
  - When the runtime re-enqueues itself, it does **not** pass these inputs — only the first queue cycle carries them.
24
25
 
@@ -236,6 +236,18 @@ A delivery executes the workflow body inline, so the handler responds only once
236
236
 
237
237
  Maximum gap in milliseconds between response body chunks from the workflow handler before the delivery is failed and redelivered. Default: `0` (no deadline). The same caution as `WORKFLOW_POSTGRES_HEADERS_TIMEOUT_MS` applies.
238
238
 
239
+ ### `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`
240
+
241
+ Seconds a running delivery's job lock may go unrenewed before another process releases the job for redelivery. Default: `0` (off). `30` is a good value when more than one process shares the database. Programmatic option: `jobLockStaleSeconds`.
242
+
243
+ When set, a running delivery renews its lock every quarter of this window, and at least every 10 seconds. When a process dies mid-delivery, another process redelivers its jobs within about one and a half windows (about 45 seconds at `30`), instead of after Graphile Worker's fixed 4 hour stale-lock reset or the next restart.
244
+
245
+ Use the same value on every process that shares the database, and keep it well above the longest a process can go without running its timers (synchronous work that blocks the event loop) or getting a pool connection. A delivery whose renewals stall past the window is redelivered while it still runs.
246
+
247
+ It's off by default because of rolling upgrades. A process on an earlier version doesn't renew its locks, so a process that has this on would redeliver any of that process's deliveries that run longer than the window. When the earlier-version process then finishes such a delivery, its acknowledgement, which isn't fenced on the lock holder, can delete the redelivered job's row, and the redelivery loses its retry.
248
+
249
+ To turn it on, set `WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS=30` (or `jobLockStaleSeconds: 30`) on every process that shares the database, once all of them run a version that includes this option.
250
+
239
251
  ### Programmatic configuration
240
252
 
241
253
  {/* @skip-typecheck: incomplete code sample */}
@@ -256,6 +268,7 @@ The Postgres World uses PostgreSQL as a durable backend:
256
268
 
257
269
  - **Storage** - Workflow runs, events, steps, and hooks are stored in PostgreSQL tables
258
270
  - **Job Queue** - [graphile-worker](https://github.com/graphile/worker) handles reliable job processing with retries
271
+ - **Crash Recovery** - The next `start()` re-enqueues active runs. With [`WORKFLOW_POSTGRES_JOB_LOCK_STALE_SECONDS`](#workflow_postgres_job_lock_stale_seconds) set, a running delivery also renews its job lock, and if its process dies, any other process redelivers the job once its lock has gone unrenewed for that many seconds
259
272
  - **Streaming** - PostgreSQL NOTIFY/LISTEN enables real-time event distribution
260
273
 
261
274
  This architecture ensures workflows survive application restarts with all state reliably persisted. For implementation details, see the [source code](https://github.com/vercel/workflow/tree/main/packages/world-postgres).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workflow",
3
- "version": "4.8.15",
3
+ "version": "4.8.17",
4
4
  "description": "Workflow SDK - Build durable, resilient, and observable workflows",
5
5
  "main": "dist/typescript-plugin.cjs",
6
6
  "type": "module",
@@ -57,18 +57,18 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "ms": "2.1.3",
60
- "@workflow/astro": "4.0.30",
61
- "@workflow/cli": "4.3.19",
60
+ "@workflow/astro": "4.0.32",
61
+ "@workflow/cli": "4.3.21",
62
+ "@workflow/core": "4.8.17",
62
63
  "@workflow/errors": "4.2.2",
63
64
  "@workflow/typescript-plugin": "4.0.3",
64
65
  "@workflow/utils": "4.1.4",
65
- "@workflow/core": "4.8.15",
66
- "@workflow/nest": "4.0.31",
67
- "@workflow/nitro": "4.1.21",
68
- "@workflow/nuxt": "4.0.31",
69
- "@workflow/sveltekit": "4.0.30",
70
- "@workflow/next": "4.1.19",
71
- "@workflow/rollup": "4.0.30"
66
+ "@workflow/next": "4.1.21",
67
+ "@workflow/nest": "4.0.33",
68
+ "@workflow/nitro": "4.1.23",
69
+ "@workflow/nuxt": "4.0.33",
70
+ "@workflow/sveltekit": "4.0.32",
71
+ "@workflow/rollup": "4.0.32"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@types/ms": "2.1.0",