-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reduce the number of parallel file reads on Windows to avoid EMF…
…ILE type errors (#6009) * use createBatches to batch assets for Pages assets upload * pages assets are already batched don't batch a batch * reduce pages assets MAX_BUCKET_FILE_COUNT on windows * Add changeset * Add comment --------- Co-authored-by: Peter Bacon Darwin <[email protected]>
- Loading branch information
1 parent
8293ab5
commit 169a9fa
Showing
5 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: reduce the number of parallel file reads on Windows to avoid EMFILE type errors | ||
|
||
Fixes #1586 |
30 changes: 30 additions & 0 deletions
30
packages/wrangler/src/__tests__/utils/create-batches.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { createBatches } from "../../utils/create-batches"; | ||
|
||
// split a template string into an array of chars (convenience util to make writing inputs/outputs easier) | ||
const s = (input: TemplateStringsArray) => input[0].split(""); | ||
|
||
describe("createBatches", () => { | ||
const data = [ | ||
{ | ||
input: s`abcde`, | ||
batchSize: 2, | ||
output: [s`ab`, s`cd`, s`e`], | ||
}, | ||
{ | ||
input: s`abcdefgh`, | ||
batchSize: 3, | ||
output: [s`abc`, s`def`, s`gh`], | ||
}, | ||
{ | ||
input: s`abcdefghijklmnopqrstuvwxyz`, | ||
batchSize: 6, | ||
output: [s`abcdef`, s`ghijkl`, s`mnopqr`, s`stuvwx`, s`yz`], | ||
}, | ||
]; | ||
|
||
for (const { input, batchSize, output } of data) { | ||
test(`${input} in batches of ${batchSize}`, () => { | ||
expect([...createBatches(input, batchSize)]).toEqual(output); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export function* createBatches<T>( | ||
array: T[], | ||
size: number | ||
): IterableIterator<T[]> { | ||
for (let i = 0; i < array.length; i += size) { | ||
yield array.slice(i, i + size); | ||
} | ||
} |