Skip to content

Commit 22fc782

Browse files
committed
fix(run-multiple): avoid temp.mjs filename collision across forked processes
When run-multiple forks N concurrent processes, each process transpiles the same .ts files (config, helpers, includes) to identically named *.temp.mjs files. A process that finishes first deletes its temp file, causing other processes that haven't imported it yet to fail with "Cannot find module *.temp.mjs". Fix: embed process.pid in the temp filename so every worker writes its own isolated copy. Cleanup still works because allTempFiles is built from transpiledFiles.values(), which already contains the pid-suffixed paths. The .includes('.temp.mjs') substring check in step/base.js continues to match the new *.{pid}.temp.mjs filenames. Fixes #5642
1 parent eba4a62 commit 22fc782

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/utils/typescript.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,9 @@ const __dirname = __dirname_fn(__filename);
385385
)
386386

387387
// Write the transpiled file with updated imports
388-
const tempFile = filePath.replace(/\.ts$/, '.temp.mjs')
388+
// Use process.pid in the filename to avoid collisions when run-multiple forks
389+
// several processes that all transpile the same .ts files concurrently.
390+
const tempFile = filePath.replace(/\.ts$/, `.${process.pid}.temp.mjs`)
389391
fs.writeFileSync(tempFile, jsContent)
390392
transpiledFiles.set(filePath, tempFile)
391393
}

0 commit comments

Comments
 (0)