Skip to content

Commit

Permalink
fix: instruct api to exclude script content on worker upload (#1248)
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 authored Jun 14, 2022
1 parent e5a3814 commit db8a0bb
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 @@ -5347,6 +5347,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 doesn't get included in the response
excludeScript: "true",
})
)
).available_on_subdomain;
}
Expand Down

0 comments on commit db8a0bb

Please sign in to comment.