fix: race condition in writeStats#711
Merged
valscion merged 2 commits intowebpack:mainfrom Mar 2, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #711 +/- ##
==========================================
+ Coverage 71.60% 76.30% +4.69%
==========================================
Files 17 17
Lines 979 979
Branches 357 357
==========================================
+ Hits 701 747 +46
+ Misses 242 205 -37
+ Partials 36 27 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
valscion
approved these changes
Mar 2, 2026
Member
valscion
left a comment
There was a problem hiding this comment.
Looks good to me! Would you be so kind and write a changelog entry under the UNRELEASED section and this this as a bug fix?
Contributor
Author
Sure! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a race condition that the
writeStatswould resolve before the FS operation finished, which may lead to incorrect content instats.json.Now instead of manually listen to the
endanderrorevent, we use thepipelineAPI fromnode:stream/promiseto handle error and promise resolving for us. ThepipelineAPI has been added in Node.js v15.0.0, which should work since we haveengines.node>= 20.9.0 now.What kind of change does this PR introduce?
a fix
Did you add tests for your changes?
Yes. And the test would fail without the fix.
Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
Nothing.
Use of AI
Yes. We use AI to find the race condition in
writeStatsfunction and use AI to generate the fix and the test.I've read and understanded every line of the code I submitted.