-
-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should report errors if stats was being accessed after the compi…
…ler was closed (#8561)
- Loading branch information
Showing
5 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
packages/rspack-test-tools/tests/compilerCases/compiler-stats-shutdown.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,41 @@ | ||
|
||
let resolveCompilerStats; | ||
let compilerStats = new Promise((resolve) => { | ||
resolveCompilerStats = resolve | ||
}); | ||
|
||
class MyPlugin { | ||
apply(compiler) { | ||
compiler.hooks.done.tap("Plugin", stats => { | ||
resolveCompilerStats(stats) | ||
}); | ||
} | ||
} | ||
|
||
/** @type {import('../../dist').TCompilerCaseConfig} */ | ||
module.exports = { | ||
description: "should be called every compilation", | ||
options(context) { | ||
return { | ||
context: context.getSource(), | ||
entry: "./d", | ||
plugins: [new MyPlugin()] | ||
}; | ||
}, | ||
async build(_, compiler) { | ||
await new Promise(resolve => { | ||
compiler.run((err, stats) => { | ||
compiler.close(() => { | ||
// Should be able to access `Stats` within the same tick of closing. | ||
expect(() => stats.compilation).not.toThrow(); | ||
resolve() | ||
}) | ||
}); | ||
}); | ||
}, | ||
async check() { | ||
let stats = await compilerStats; | ||
// Should not be able to access `Stats` after the compiler was shutdown. | ||
expect(() => stats.compilation).toThrow("Unable to access `Stats` after the compiler was shutdown") | ||
} | ||
}; |
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
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
d249e62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open
d249e62
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open