fix: use globalThis for step registry to survive module duplication#1373
fix: use globalThis for step registry to survive module duplication#1373jcourson-bg wants to merge 2 commits intovercel:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 91bb717 The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@jcourson-bg is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
Fixes #1374 |
|
I've been looking into the same error, I don't think this fully fixes I think this issue was introduced in my last PR #1334 - its not an issue with those changes, but I think those changes did expose an issue in the workflow/next package I think the real issues is that Next starts listening for graphile jobs before everything is actually loaded bc we're using lazy / deferred loading, so the .wellknown/workflow routes aren't actually ready sometimes and will fail if Graphile starts dequeuing too early |
Summary
registeredStepsonglobalThisviaSymbol.for()so all module instances share a single registry, matching the existing pattern inworld.tsProblem
In Turbopack dev mode,
private.jscan be instantiated as separate module instances across different chunk contexts.registerStepFunction(called from the generated step route) andgetStepFunction(called from the step handler) end up operating on differentMapinstances, causing "Step not found" errors.Test plan
pnpm buildpassespnpm testinpackages/core