Skip to content

Commit

Permalink
Revert #5632 (#6002)
Browse files Browse the repository at this point in the history
  • Loading branch information
GregBrimble authored Jun 10, 2024
1 parent 152a6cd commit f1f1834
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-bees-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Revert a change in 3.60.0 which incorrectly batched assets for Pages uploads (/~https://github.com/cloudflare/workers-sdk/pull/5632).
27 changes: 10 additions & 17 deletions packages/wrangler/src/pages/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,23 +205,16 @@ export const upload = async (
const doUpload = async (): Promise<void> => {
// Populate the payload only when actually uploading (this is limited to 3 concurrent uploads at 50 MiB per bucket meaning we'd only load in a max of ~150 MiB)
// This is so we don't run out of memory trying to upload the files.
const payload: UploadPayloadFile[] = [];

for (let i = 0; i < bucket.files.length; i += 1000) {
// only read up to 1000 files, from disk, at a time to avoid `EMFILE` error (on Windows)
payload.push(
...(await Promise.all(
bucket.files.slice(i * 1000, (i + 1) * 1000).map(async (file) => ({
key: file.hash,
value: (await readFile(file.path)).toString("base64"),
metadata: {
contentType: file.contentType,
},
base64: true,
}))
))
);
}
const payload: UploadPayloadFile[] = await Promise.all(
bucket.files.map(async (file) => ({
key: file.hash,
value: (await readFile(file.path)).toString("base64"),
metadata: {
contentType: file.contentType,
},
base64: true,
}))
);

try {
logger.debug("POST /pages/assets/upload");
Expand Down

0 comments on commit f1f1834

Please sign in to comment.