Skip to content

Commit b21f3b7

Browse files
fix(server): prevent Windows PTY helper crashes in watch mode (#14179)
1 parent 7733bc8 commit b21f3b7

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

‎patches/[email protected]‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
diff --git a/lib/windowsConoutConnection.js b/lib/windowsConoutConnection.js
2+
--- a/lib/windowsConoutConnection.js
3+
+++ b/lib/windowsConoutConnection.js
4+
@@ -63,7 +63,11 @@
5+
conoutPipeName: _conoutPipeName
6+
};
7+
var scriptPath = __dirname.replace('node_modules.asar', 'node_modules.asar.unpacked');
8+
- this._worker = new worker_threads_1.Worker((0, path_1.join)(scriptPath, 'worker/conoutSocketWorker.js'), { workerData: workerData });
9+
+ // Node's watch mode reports dependencies through worker messages.
10+
+ // Keep the host's watch environment out of this protocol worker.
11+
+ var workerEnv = Object.assign({}, process.env);
12+
+ delete workerEnv.WATCH_REPORT_DEPENDENCIES;
13+
+ this._worker = new worker_threads_1.Worker((0, path_1.join)(scriptPath, 'worker/conoutSocketWorker.js'), { workerData: workerData, env: workerEnv, execArgv: [] });
14+
this._worker.on('message', function (message) {
15+
switch (message) {
16+
case 1 /* ConoutWorkerMessage.READY */:
17+
diff --git a/lib/windowsPtyAgent.js b/lib/windowsPtyAgent.js
18+
--- a/lib/windowsPtyAgent.js
19+
+++ b/lib/windowsPtyAgent.js
20+
@@ -218,8 +218,14 @@
21+
return Promise.resolve([]);
22+
}
23+
return new Promise(function (resolve) {
24+
- var agent = (0, child_process_1.fork)(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()]);
25+
+ // Node's watch mode sends its own messages over the helper's IPC channel.
26+
+ var agentEnv = Object.assign({}, process.env);
27+
+ delete agentEnv.WATCH_REPORT_DEPENDENCIES;
28+
+ var agent = (0, child_process_1.fork)(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()], { env: agentEnv, execArgv: [] });
29+
agent.on('message', function (message) {
30+
+ if (!Array.isArray(message.consoleProcessList)) {
31+
+ return;
32+
+ }
33+
clearTimeout(timeout);
34+
resolve(message.consoleProcessList);
35+
});

‎pnpm-lock.yaml‎

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ patchedDependencies:
196196
197197
198198
199+
199200
200201
201202

0 commit comments

Comments
 (0)