Skip to content

Commit 0b3e6bf

Browse files
authored
Remove limit on max parallel file ops (#5986)
1 parent 95b53ee commit 0b3e6bf

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

docs/configuration-options/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,9 +637,9 @@ Note that when a relative path is directly marked as "external" using the [`exte
637637
| -------: | :------------------------------ |
638638
| Type: | `number` |
639639
| CLI: | `--maxParallelFileOps <number>` |
640-
| Default: | 20 |
640+
| Default: | `Infinity` |
641641

642-
Limits the number of files rollup will open in parallel when reading modules or writing chunks. Without a limit or with a high enough value, builds can fail with an "EMFILE: too many open files". This depends on how many open file handles the operating system allows.
642+
Limits the number of files rollup will open in parallel when reading modules or writing chunks. Without a limit or with a high enough value, builds can fail with an "EMFILE: too many open files". This depends on how many open file handles the operating system allows. If you set the limit too low and use plugins that rely on the [`this.load`](../plugin-development/index.md#this-load) context function, such as the `commonjs` plugin, then it can happen that builds stall without an error message as it limits the number of parallel `load` calls.
643643

644644
### onLog
645645

src/utils/options/normalizeInputOptions.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,8 @@ const getMaxParallelFileOps = (
176176
config: InputOptions
177177
): NormalizedInputOptions['maxParallelFileOps'] => {
178178
const maxParallelFileOps = config.maxParallelFileOps;
179-
if (typeof maxParallelFileOps === 'number') {
180-
if (maxParallelFileOps <= 0) return Infinity;
181-
return maxParallelFileOps;
182-
}
183-
return 20;
179+
if (typeof maxParallelFileOps !== 'number' || maxParallelFileOps <= 0) return Infinity;
180+
return maxParallelFileOps;
184181
};
185182

186183
const getModuleContext = (

test/function/samples/options-hook/_config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ module.exports = defineTest({
1111
name: 'test-plugin',
1212
buildStart(options) {
1313
// The fs option is not json stringifiable
14-
const { fs, ...restOptions } = options;
14+
const { fs, maxParallelFileOps, ...restOptions } = options;
1515
assert.ok(fs);
16+
assert.strictEqual(maxParallelFileOps, Infinity);
1617
assert.deepStrictEqual(JSON.parse(JSON.stringify(restOptions)), {
1718
context: 'undefined',
1819
experimentalCacheExpiry: 10,
@@ -21,7 +22,6 @@ module.exports = defineTest({
2122
jsx: false,
2223
logLevel: 'info',
2324
makeAbsoluteExternalsRelative: 'ifRelativeSource',
24-
maxParallelFileOps: 20,
2525
perf: false,
2626
plugins: [
2727
{

0 commit comments

Comments
 (0)