Skip to content

fix(cloudflare): route asset upload sessions to the dispatch-namespace endpoint - #1405

Open
pltoledo wants to merge 1 commit into
alchemy-run:mainfrom
pltoledo:fix/dispatch-namespace-assets-upload-session
Open

fix(cloudflare): route asset upload sessions to the dispatch-namespace endpoint#1405
pltoledo wants to merge 1 commit into
alchemy-run:mainfrom
pltoledo:fix/dispatch-namespace-assets-upload-session

Conversation

@pltoledo

Copy link
Copy Markdown

Asset upload sessions for Workers deployed into a dispatch namespace were created on the account-level endpoint, so the completion JWT comes back scoped to the wrong script identity and the namespaced script PUT is rejected (400 on a new script, 500 on an existing one).

uploadAssets now takes the namespace and picks the endpoint the same way the namespace-aware helpers in WorkerProvider already do (putWorkerScript, getScriptSettings, deleteWorkerScript):

const session = dispatchNamespace
  ? yield* wfp.createDispatchNamespaceScriptAssetUpload({
      accountId,
      dispatchNamespace,
      scriptName: workerName,
      manifest: assets.manifest,
    })
  : yield* workers.createScriptAssetUpload({
      accountId,
      scriptName: workerName,
      manifest: assets.manifest,
    });

The version-upload call site is unchanged: namespaced scripts have no versions API and the provider already rejects version + namespace.

We run this change in production as a patch over 2.0.0-beta.72 (Workers for Platforms platform publishing sites into a dispatch namespace, static assets + prebuilt SSR workers); with it, Worker with namespace and assets deploys end to end.

…e endpoint

When a Worker deploys into a Workers for Platforms dispatch namespace, the
asset upload session was still created on the account-level endpoint. The
completion JWT comes back scoped to the wrong script identity, and the
namespaced script PUT is rejected (400 on a new script, 500 on an existing
one). Thread dispatchNamespace through uploadAssets and create the session
via createDispatchNamespaceScriptAssetUpload when set, mirroring the
namespace-aware helpers already in WorkerProvider (putWorkerScript,
getScriptSettings, deleteWorkerScript). The version-upload path is
unchanged: namespaced scripts have no versions API and the provider
already rejects that combination.
@pltoledo
pltoledo force-pushed the fix/dispatch-namespace-assets-upload-session branch from 6c35c32 to 70c380f Compare August 29, 2026 16:01

@sam-goodwin sam-goodwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a regression test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants