Skip to content

Commit

Permalink
Fix max asset count message (#6627)
Browse files Browse the repository at this point in the history
* Fixes asset count error message to properly report count of assets

* Error if > 20000 assets rather than >= 20000

Co-authored-by: Pete Bacon Darwin <[email protected]>

---------

Co-authored-by: Pete Bacon Darwin <[email protected]>
  • Loading branch information
GregBrimble and petebacondarwin authored Sep 6, 2024
1 parent c365e61 commit 5936282
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-brooms-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"miniflare": patch
---

fix: Fixes max asset count error message to properly report count of assets
15 changes: 7 additions & 8 deletions packages/miniflare/src/plugins/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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` +
Expand All @@ -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;
};

Expand Down

0 comments on commit 5936282

Please sign in to comment.