| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The atomic counter used to signal CWD changes to worker threads was being incremented before chdir() completed, creating a race window where workers could cache stale directory paths with the new counter value. This caused process.cwd() in workers to return incorrect values until the next chdir() call. Fix by reordering operations: call originalChdir() first, then increment the counter. This ensures workers never cache stale data while believing it is current. Reported-by: Giulio Comi Reported-by: Caleb Everett
|
cc @nodejs/tsc |
Sorry, something went wrong.
|
FYI, a PR was opened by the community reporter at #61664. |
Sorry, something went wrong.
There was a problem hiding this comment.
Nice catch.
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #61725 +/- ##
==========================================
+ Coverage 88.53% 89.75% +1.21%
==========================================
Files 703 675 -28
Lines 208538 204525 -4013
Branches 40224 39306 -918
==========================================
- Hits 184629 183565 -1064
+ Misses 15912 13241 -2671
+ Partials 7997 7719 -278
... and 199 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The atomic counter used to signal CWD changes to worker threads was
being incremented before chdir() completed, creating a race window
where workers could cache stale directory paths with the new counter
value. This caused process.cwd() in workers to return incorrect values
until the next chdir() call.
Fix by reordering operations: call originalChdir() first, then
increment the counter. This ensures workers never cache stale data
while believing it is current.
A unit test for this fix is not feasible as it would be too flaky due to the timing-dependent nature of the race condition.
Reported-by: Giulio Comi
Reported-by: Caleb Everett