-
Notifications
You must be signed in to change notification settings - Fork 222
Step functions not found when using Turbopack dev mode with non-local world backends #1374
Description
Bug Report
Description
When running a Next.js app in Turbopack dev mode with a non-local world backend (e.g. postgres via Graphile Worker), step functions fail with:
Step "step//./workflows/chat/steps/load-context//loadChatContext" not found
Root Causes
The generated step route (app/.well-known/workflow/v1/step/route.js) calls registerStepFunction for each step, but Turbopack only compiles it on HTTP request for dev. The postgres world invokes steps in-process via Graphile Worker, so the route never loads and the registry stays empty.
registeredSteps in private.ts is a plain Map(). If Turbopack creates duplicate module instances, registerStepFunction and getStepFunction use different Maps. world.ts already avoids this with globalThis[Symbol.for(...)].
Fix
Use globalThis + Symbol.for for the step registry and document that non-local worlds need to import the step route in instrumentation.ts:
if (process.env.NEXT_RUNTIME !== "edge") {
const { getWorld } = await import("workflow/runtime");
await getWorld().start?.();
await import("./app/.well-known/workflow/v1/step/route.js");
}