workflow 4.8.14 → 4.8.16

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.
@@ -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.14",
3
+ "version": "4.8.16",
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/cli": "4.3.18",
61
- "@workflow/core": "4.8.14",
60
+ "@workflow/astro": "4.0.31",
61
+ "@workflow/cli": "4.3.20",
62
+ "@workflow/core": "4.8.16",
62
63
  "@workflow/errors": "4.2.2",
63
64
  "@workflow/typescript-plugin": "4.0.3",
64
65
  "@workflow/utils": "4.1.4",
65
- "@workflow/next": "4.1.18",
66
- "@workflow/nest": "4.0.30",
67
- "@workflow/nitro": "4.1.20",
68
- "@workflow/nuxt": "4.0.30",
69
- "@workflow/sveltekit": "4.0.29",
70
- "@workflow/rollup": "4.0.29",
71
- "@workflow/astro": "4.0.29"
66
+ "@workflow/next": "4.1.20",
67
+ "@workflow/nest": "4.0.32",
68
+ "@workflow/nitro": "4.1.22",
69
+ "@workflow/nuxt": "4.0.32",
70
+ "@workflow/sveltekit": "4.0.31",
71
+ "@workflow/rollup": "4.0.31"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@types/ms": "2.1.0",