Skip to content

Commit

Permalink
fix: instruct api to exclude script content on worker upload
Browse files Browse the repository at this point in the history
When we upload a script bundle, we get the actual content of the script back in the response. Sometimes that script can be large (depending on whether the upload was large), and currently it may even be a badly escaped string. We can pass a queryparam `excludeScript` that, as it implies, exclude the script content in the response. This fix does that.

Fixes #1222
  • Loading branch information
threepointone committed Jun 13, 2022
1 parent 9dae5af commit 919b862
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .changeset/curvy-donuts-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"wrangler": patch
---

fix: instruct api to exclude script content on worker upload

When we upload a script bundle, we get the actual content of the script back in the response. Sometimes that script can be large (depending on whether the upload was large), and currently it may even be a badly escaped string. We can pass a queryparam `excludeScript` that, as it implies, exclude the script content in the response. This fix does that.

Fixes https://github.com/cloudflare/wrangler2/issues/1222
1 change: 1 addition & 0 deletions packages/wrangler/src/__tests__/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5294,6 +5294,7 @@ function mockUploadWorkerRequest(
expect(envName).toEqual(env);
}
expect(queryParams.get("include_subdomain_availability")).toEqual("true");
expect(queryParams.get("excludeScript")).toEqual("true");
const formBody = body as FormData;
if (expectedEntry !== undefined) {
expect(await (formBody.get("index.js") as File).text()).toMatch(
Expand Down
7 changes: 6 additions & 1 deletion packages/wrangler/src/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,12 @@ export default async function publish(props: Props): Promise<void> {
method: "PUT",
body: createWorkerUploadForm(worker),
},
new URLSearchParams({ include_subdomain_availability: "true" })
new URLSearchParams({
include_subdomain_availability: "true",
// pass excludeScript so the whole body of the script dorsn't
// get returned in the response
excludeScript: "true",
})
)
).available_on_subdomain;
}
Expand Down

0 comments on commit 919b862

Please sign in to comment.