From 5936282bfbda848b465396a70f6334988d1a57a0 Mon Sep 17 00:00:00 2001 From: Greg Brimble Date: Fri, 6 Sep 2024 14:09:04 -0400 Subject: [PATCH] Fix max asset count message (#6627) * Fixes asset count error message to properly report count of assets * Error if > 20000 assets rather than >= 20000 Co-authored-by: Pete Bacon Darwin --------- Co-authored-by: Pete Bacon Darwin --- .changeset/khaki-brooms-matter.md | 5 +++++ packages/miniflare/src/plugins/assets/index.ts | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 .changeset/khaki-brooms-matter.md diff --git a/.changeset/khaki-brooms-matter.md b/.changeset/khaki-brooms-matter.md new file mode 100644 index 000000000000..215fd41920ce --- /dev/null +++ b/.changeset/khaki-brooms-matter.md @@ -0,0 +1,5 @@ +--- +"miniflare": patch +--- + +fix: Fixes max asset count error message to properly report count of assets diff --git a/packages/miniflare/src/plugins/assets/index.ts b/packages/miniflare/src/plugins/assets/index.ts index 044d9bcc414e..8f5a0284b2e4 100644 --- a/packages/miniflare/src/plugins/assets/index.ts +++ b/packages/miniflare/src/plugins/assets/index.ts @@ -179,14 +179,6 @@ const walk = async (dir: string) => { if (filestat.isSymbolicLink() || filestat.isDirectory()) { return; } else { - if (counter >= MAX_ASSET_COUNT) { - throw new Error( - `Maximum number of assets exceeded.\n` + - `Cloudflare Workers supports up to ${MAX_ASSET_COUNT.toLocaleString()} assets in a version. We found ${counter.toLocaleString()} files in the specified assets directory "${dir}".\n` + - `Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT.toLocaleString()} files, and that you have specified your assets directory correctly.` - ); - } - if (filestat.size > MAX_ASSET_SIZE) { throw new Error( `Asset too large.\n` + @@ -210,6 +202,13 @@ const walk = async (dir: string) => { } }) ); + if (counter > MAX_ASSET_COUNT) { + throw new Error( + `Maximum number of assets exceeded.\n` + + `Cloudflare Workers supports up to ${MAX_ASSET_COUNT.toLocaleString()} assets in a version. We found ${counter.toLocaleString()} files in the specified assets directory "${dir}".\n` + + `Ensure your assets directory contains a maximum of ${MAX_ASSET_COUNT.toLocaleString()} files, and that you have specified your assets directory correctly.` + ); + } return manifest; };