Skip to content

Commit 313db6f

Browse files
authored
fix(deploy): upload Worker Loader bindings when secrets are pinned (#744)
## Problem When the active Worker version has any secret, `void deploy --platform cloudflare` uploads through the pinned-secret uploader instead of `cf`'s. That uploader rebuilds every binding in `bindingsFromOutput`, which has no case for the `worker-loader` binding that `cf` emits for `worker_loaders`, so it reaches `default` and throws: ``` ■ deploy: Cloudflare could not publish the Worker atomically (exit 1); inspect production status before retrying. Cloudflare binding LOADER cannot be uploaded with pinned secrets. ``` An app that uses Dynamic Workers (`cloudflare: { worker_loaders: [{ binding: 'LOADER' }] }`) and has any secret can't be deployed. I hit it with `--atomic`; reading the code, the non-atomic `versions.upload` path uses the same uploader whenever `output.activeSecrets` is set. This is the same failure as #462 (`ratelimits`), for another binding type. ## Fix Map `worker-loader` to the `worker_loader` binding type in `bindingsFromOutput`. `worker_loader` is the Worker metadata binding type that Cloudflare's own packages use (`@cloudflare/workers-utils`). ## Verification - `verifyPinnedUpload` now declares `worker_loaders` and expects `{ name: 'LOADER', type: 'worker_loader' }`. Without the source change both pinned-upload tests fail with the error above; with it, `cf-version-runner.test.ts` passes (127 tests). `vp fmt --check` and `vp lint` pass on the changed files, and `packages/void` typechecks. - Deployed a real app that has `worker_loaders` and a required secret, using void 1.6.2 with this change (`void deploy --platform cloudflare --atomic`). The upload was accepted, and the live version lists `LOADER: worker_loader` next to the inherited secret (`secret_text`). Before the change, the same deploy stopped with the error above. - Not covered: I did not exercise `env.LOADER` at runtime on that deployment. I only checked that the upload is accepted and the binding is present on the live version.
1 parent 4d51362 commit 313db6f

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎packages/void/src/cli/cf-version-api.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ function bindingsFromOutput(
283283
case 'version-metadata':
284284
bindings.push({ name, type: 'version_metadata' });
285285
break;
286+
case 'worker-loader':
287+
bindings.push({ name, type: 'worker_loader' });
288+
break;
286289
default:
287290
throw new Error(`Cloudflare binding ${name} cannot be uploaded with pinned secrets.`);
288291
}

‎packages/void/test/unit/cf-version-runner.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ async function verifyPinnedUpload(atomic: boolean): Promise<void> {
11111111
vectorize: [{ binding: 'VECTORS', index_name: 'vectors' }],
11121112
browser: { binding: 'BROWSER' },
11131113
images: { binding: 'IMAGES' },
1114+
worker_loaders: [{ binding: 'LOADER' }],
11141115
dispatch_namespaces: [
11151116
{
11161117
binding: 'DISPATCH',
@@ -1287,6 +1288,7 @@ async function verifyPinnedUpload(atomic: boolean): Promise<void> {
12871288
{ name: 'VECTORS', type: 'vectorize', index_name: 'vectors' },
12881289
{ name: 'BROWSER', type: 'browser' },
12891290
{ name: 'IMAGES', type: 'images' },
1291+
{ name: 'LOADER', type: 'worker_loader' },
12901292
{
12911293
name: 'DISPATCH',
12921294
type: 'dispatch_namespace',

0 commit comments

Comments
 (0)