Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restrict parallel execution of load hook as well. (#4200)
Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
- Loading branch information
1 parent
b34a411
commit f11aed1
Showing
8 changed files
with
50 additions
and
3 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
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 @@ | ||
export const x1 = 1; |
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 @@ | ||
export const x2 = 2; |
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 @@ | ||
export const x3 = 3; |
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 @@ | ||
export const x4 = 4; |
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 @@ | ||
export const x5 = 5; |
37 changes: 37 additions & 0 deletions
37
test/function/samples/max-parallel-file-reads-with-plugin/_config.js
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,37 @@ | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
const fsReadFile = fs.readFile; | ||
let currentReads = 0; | ||
let maxReads = 0; | ||
|
||
module.exports = { | ||
description: 'maxParallelFileReads with plugin', | ||
options: { | ||
maxParallelFileReads: 3, | ||
plugins: [ | ||
{ | ||
async load(id) { | ||
return new Promise((fulfil, reject) => | ||
fs.readFile(id, 'utf-8', (err, contents) => (err ? reject(err) : fulfil(contents))) | ||
); | ||
} | ||
} | ||
] | ||
}, | ||
before() { | ||
fs.readFile = (path, options, callback) => { | ||
console.log('mock read'); | ||
currentReads++; | ||
maxReads = Math.max(maxReads, currentReads); | ||
fsReadFile(path, options, (err, data) => { | ||
currentReads--; | ||
callback(err, data); | ||
}); | ||
}; | ||
}, | ||
after() { | ||
fs.readFile = fsReadFile; | ||
assert.strictEqual(maxReads, 3, 'Wrong number of parallel file reads: ' + maxReads); | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/function/samples/max-parallel-file-reads-with-plugin/main.js
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,5 @@ | ||
export * from './1'; | ||
export * from './2'; | ||
export * from './3'; | ||
export * from './4'; | ||
export * from './5'; |