#1253

Durable sessions: record a queue namespace on libfx's runs so a Workflow World's restart recovery doesn't fail them

Openpranaygpopened 1mo ago

What happens

On world-local and world-postgres, a World's start() re-enqueues every run that's still pending or running (reenqueueActiveRuns in @workflow/world). Since vercel/workflow#4835 (released in @workflow/world 5.0.4, @workflow/world-local 5.1.1, @workflow/world-postgres 5.0.4) it sends each run back to the queue namespace the run recorded when it was created (run_created → executionContext.queueNamespace). A run that recorded none goes to the starting process's default prefix, __wkf_workflow_.

libfx's run_created records no namespace (createRun in sdk/durable.js at 735670679a: eventData: { deploymentId, workflowName: "libfx/session", input }). So in an app that also uses the Workflow SDK and shares the World's data directory or database, the Workflow SDK's World recovers every open libfx session on its own route at startup. The Workflow handler doesn't know libfx/session and fails the run (WorkflowNotRegisteredError). Seen under next dev with world-local: an open libfx session ended failed after a restart.

Proposal

  1. Record the namespace libfx already uses (its prefix is __libfx_wkf_workflow_) when it creates a run:

    eventData: { deploymentId, workflowName: "libfx/session", input, executionContext: { queueNamespace: "libfx" } }

    Recovery then sends the run to __libfx_wkf_workflow_libfx/session with { runId }. That's a valid queue name under libfx's prefix, so it reaches libfx's handler instead of the Workflow SDK's.

  2. Handle that message. Today deliverTo returns without doing anything when a delivery has no input, which is safe: the session is left alone, not failed. Better still, treat { runId } as "continue this session if it has an unfinished turn", so a restart resumes libfx sessions the same way it resumes workflow runs.

Sessions created before the change record no namespace and stay exposed until they finish. Item 1 alone stops new sessions from being failed.

Activity

0

No activity yet.