fix(typescript): unique temp file names to fix run-multiple race (#5642)#5643
Merged
DavertMik merged 1 commit intoJun 17, 2026
Merged
Conversation
…eceptjs#5642) Transpiled TypeScript files were written to a fixed "<source>.temp.mjs" path next to the source. Under run-multiple, every forked worker transpiles the same files to the same temp paths and cleans them up independently, so one worker's cleanup deletes files the others still need to import — surfacing as "Cannot find module *.temp.mjs". Include process.pid plus a random suffix in the temp file name so each worker writes (and removes) its own files. The names still end in ".temp.mjs", so stack-trace remapping and fixErrorStack keep working. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3 tasks
DavertMik
approved these changes
Jun 17, 2026
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.
Problem
Fixes #5642.
Under
run-multiple, tests intermittently fail withCannot find module *.temp.mjs/ENOENT.The built-in TypeScript transpiler writes each transpiled file to a fixed
<source>.temp.mjspath next to the source.run-multipleforks one OS process perbrowsersentry, all at once, and each worker transpiles the same config/helper/include files to the same temp paths and then deletes them on cleanup. Workers race over the shared paths, so one worker's cleanup removes files another worker still needs to import.Fix
Include
process.pidplus a short random suffix in the temp file name (<source>.<pid>.<rand>.temp.mjs), so each worker writes and removes only its own files.requirerewrites resolve through the existingtranspiledFilesmap, so rewritten references automatically point at the unique names — no other changes needed..temp.mjs, so the stack-trace remapping inlib/step/base.jsandfixErrorStackkeep working unchanged.Test
Added
test/unit/utils/typescript_test.js: two transpilation runs of the same fixture must produce disjoint temp-file sets. It fails on the old code (temp files were shared between invocations) and passes with the fix.🤖 Generated with Claude Code