Skip to content

Commit 4a87b85

Browse files
authored
Set maxParallelFileOps to 1000 (#5992)
This is a quick fix compromise until we find a better solution to enforce the limit.
1 parent 37d1915 commit 4a87b85

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

docs/configuration-options/index.md

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

642642
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

src/utils/options/normalizeInputOptions.ts

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

183186
const getModuleContext = (

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

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

0 commit comments

Comments
 (0)