Skip to content

Commit

Permalink
During Pages and R2 validations, show sizes in MiB (consistently with…
Browse files Browse the repository at this point in the history
… the Cloudflare docs) (#4577)
  • Loading branch information
dario-piotrowicz authored Dec 8, 2023
1 parent 2b63e20 commit 4c85fe9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/eight-stingrays-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

During the R2 validation, show `MAX_UPLOAD_SIZE` errors using MiB (consistently with the Cloudflare docs)
5 changes: 5 additions & 0 deletions .changeset/itchy-knives-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

During the Pages validation, show `MAX_UPLOAD_SIZE` errors using MiB (consistently with the Cloudflare docs)
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ describe("project validate", () => {

await expect(() => runWrangler("pages project validate .")).rejects
.toThrowErrorMatchingInlineSnapshot(`
"Error: Pages only supports files up to 1.05 MB in size
logo.png is 1.05 MB in size"
"Error: Pages only supports files up to 1 MiB in size
logo.png is 1 MiB in size"
`);
});

Expand Down
5 changes: 3 additions & 2 deletions packages/wrangler/src/__tests__/r2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ describe("r2", () => {
)
).rejects.toThrowErrorMatchingInlineSnapshot(`
"Error: Wrangler only supports uploading files up to ${prettyBytes(
MAX_UPLOAD_SIZE
MAX_UPLOAD_SIZE,
{ binary: true }
)} in size
wormhole-img.png is ${prettyBytes(TOO_BIG_FILE_SIZE)} in size"
wormhole-img.png is ${prettyBytes(TOO_BIG_FILE_SIZE, { binary: true })} in size"
`);
});

Expand Down
7 changes: 5 additions & 2 deletions packages/wrangler/src/pages/validate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ export const validate = async (args: {
if (filestat.size > MAX_ASSET_SIZE) {
throw new FatalError(
`Error: Pages only supports files up to ${prettyBytes(
MAX_ASSET_SIZE
)} in size\n${name} is ${prettyBytes(filestat.size)} in size`,
MAX_ASSET_SIZE,
{ binary: true }
)} in size\n${name} is ${prettyBytes(filestat.size, {
binary: true,
})} in size`,
1
);
}
Expand Down
7 changes: 5 additions & 2 deletions packages/wrangler/src/r2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,11 @@ export function r2(r2Yargs: CommonYargsArgv) {
if (objectSize > MAX_UPLOAD_SIZE) {
throw new FatalError(
`Error: Wrangler only supports uploading files up to ${prettyBytes(
MAX_UPLOAD_SIZE
)} in size\n${key} is ${prettyBytes(objectSize)} in size`,
MAX_UPLOAD_SIZE,
{ binary: true }
)} in size\n${key} is ${prettyBytes(objectSize, {
binary: true,
})} in size`,
1
);
}
Expand Down

0 comments on commit 4c85fe9

Please sign in to comment.