Skip to content

Commit

Permalink
fix: clean up system temp directory when running.
Browse files Browse the repository at this point in the history
While the system temp directory gets cleaned up semi-regularly,
on long-running machines (e.g. CI servers), it is possible for
the PID to get reused before the system temp directory gets
cleared. When this happens, the temp directory we create as an
intermediate location for TypeScript build artifacts (to prevent
churn in the build) can end up being used for multiple builds,
even across separate apps. This can result in very bad output
from the build, including total runtime failures from things like
`require` entries including files from different builds or apps.

Prevent this by always running `fs.removeSync` on the temp output
directory prior to setting it and putting new output there.

Fixes #318.
  • Loading branch information
chriskrycho committed Sep 24, 2018
1 parent 1228ff0 commit 59ecce1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ts/lib/incremental-typescript-compiler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ module.exports = class IncrementalTypescriptCompiler {
outDir() {
if (!this._outDir) {
let outDir = path.join(tmpdir(), `e-c-ts-${process.pid}`);
fs.removeSync(outDir);

this._outDir = outDir;
fs.mkdirsSync(outDir);
}
Expand Down

0 comments on commit 59ecce1

Please sign in to comment.