Skip to content

Step functions not found when using Turbopack dev mode with non-local world backends #1374

@jcourson-bg

Description

@jcourson-bg

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");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions