Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-2.2] use separate process to probe if drive is safe to watch (…
…#14098) (#14124) * use separate process to probe if drive is safe to watch (#14098) use dedicated process to determine if it is safe to watch folders * added release-2.2
- Loading branch information
Showing
6 changed files
with
136 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ branches: | |
only: | ||
- master | ||
- release-2.1 | ||
- release-2.2 | ||
|
||
install: | ||
- npm uninstall typescript | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig-base", | ||
"compilerOptions": { | ||
"removeComments": true, | ||
"outFile": "../../../built/local/watchGuard.js" | ||
}, | ||
"files": [ | ||
"watchGuard.ts" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// <reference types="node" /> | ||
|
||
if (process.argv.length < 3) { | ||
process.exit(1); | ||
} | ||
const directoryName = process.argv[2]; | ||
const fs: { watch(directoryName: string, options: any, callback: () => {}): any } = require("fs"); | ||
// main reason why we need separate process to check if it is safe to watch some path | ||
// is to guard against crashes that cannot be intercepted with protected blocks and | ||
// code in tsserver already can handle normal cases, like non-existing folders. | ||
// This means that here we treat any result (success or exception) from fs.watch as success since it does not tear down the process. | ||
// The only case that should be considered as failure - when watchGuard process crashes. | ||
try { | ||
const watcher = fs.watch(directoryName, { recursive: true }, () => ({})) | ||
watcher.close(); | ||
} | ||
catch (_e) { | ||
} | ||
process.exit(0); |