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/curvy-ravens-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/core": patch
---

Downgrade `@types/node` to v22.19.0
5 changes: 5 additions & 0 deletions .changeset/heavy-baboons-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@workflow/world-local": patch
---

Fix long-running steps to not time out after 5 minutes
5 changes: 3 additions & 2 deletions packages/core/src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ export async function runWorkflow(
this.credentials = 'same-origin';
}

if (init?.cache !== undefined) {
this.cache = init.cache;
// `any` cast here because @types/node v22 does not yet have `cache`
if ((init as any)?.cache !== undefined) {
this.cache = (init as any).cache;
} else if (typeof this.cache !== 'string') {
this.cache = 'default';
}
Expand Down
1 change: 1 addition & 0 deletions packages/world-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@vercel/queue": "0.0.0-alpha.23",
"@workflow/world": "workspace:*",
"ulid": "^3.0.1",
"undici": "^6.19.0",
"zod": "catalog:"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions packages/world-local/src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { setTimeout } from 'node:timers/promises';
import { JsonTransport } from '@vercel/queue';
import { MessageId, type Queue, ValidQueueName } from '@workflow/world';
import { monotonicFactory } from 'ulid';
import { Agent } from 'undici';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little sad we need a 1.5MB package just to set a timeout, but I also don't see a better workaround here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Pretty lame that Node doesn't export this itself.

import z from 'zod';

// For local queue, there is no technical limit on the message visibility lifespan,
Expand All @@ -10,6 +11,11 @@ const LOCAL_QUEUE_MAX_VISIBILITY =
parseInt(process.env.WORKFLOW_LOCAL_QUEUE_MAX_VISIBILITY ?? '0', 10) ||
Infinity;

// Create a custom agent with unlimited headers timeout for long-running steps
const httpAgent = new Agent({
headersTimeout: 0,
});

export function createQueue(port?: number): Queue {
const transport = new JsonTransport();
const generateId = monotonicFactory();
Expand Down Expand Up @@ -53,11 +59,13 @@ export function createQueue(port?: number): Queue {
let defaultRetriesLeft = 3;
for (let attempt = 0; defaultRetriesLeft > 0; attempt++) {
defaultRetriesLeft--;

const response = await fetch(
`http://localhost:${port}/.well-known/workflow/v1/${pathname}`,
{
method: 'POST',
duplex: 'half',
dispatcher: httpAgent,
headers: {
'x-vqs-queue-name': queueName,
'x-vqs-message-id': messageId,
Expand Down
Loading