Skip to content
TypeScript

fix(server): prevent Windows PTY helper crashes in watch mode (#14179)

Utkarsh Patilb21f3b719133
diff --git a/patches/[email protected] b/patches/[email protected]
new file mode 100644
index 00000000000..2232766cdb6
--- /dev/null
+++ b/patches/[email protected]
@@ -0,0 +1,35 @@
+diff --git a/lib/windowsConoutConnection.js b/lib/windowsConoutConnection.js
+--- a/lib/windowsConoutConnection.js
++++ b/lib/windowsConoutConnection.js
+@@ -63,7 +63,11 @@
+ conoutPipeName: _conoutPipeName
+ };
+ var scriptPath = __dirname.replace('node_modules.asar', 'node_modules.asar.unpacked');
+- this._worker = new worker_threads_1.Worker((0, path_1.join)(scriptPath, 'worker/conoutSocketWorker.js'), { workerData: workerData });
++ // Node's watch mode reports dependencies through worker messages.
++ // Keep the host's watch environment out of this protocol worker.
++ var workerEnv = Object.assign({}, process.env);
++ delete workerEnv.WATCH_REPORT_DEPENDENCIES;
++ this._worker = new worker_threads_1.Worker((0, path_1.join)(scriptPath, 'worker/conoutSocketWorker.js'), { workerData: workerData, env: workerEnv, execArgv: [] });
+ this._worker.on('message', function (message) {
+ switch (message) {
+ case 1 /* ConoutWorkerMessage.READY */:
+diff --git a/lib/windowsPtyAgent.js b/lib/windowsPtyAgent.js
+--- a/lib/windowsPtyAgent.js
++++ b/lib/windowsPtyAgent.js
+@@ -218,8 +218,14 @@
+ return Promise.resolve([]);
+ }
+ return new Promise(function (resolve) {
+- var agent = (0, child_process_1.fork)(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()]);
++ // Node's watch mode sends its own messages over the helper's IPC channel.
++ var agentEnv = Object.assign({}, process.env);
++ delete agentEnv.WATCH_REPORT_DEPENDENCIES;
++ var agent = (0, child_process_1.fork)(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()], { env: agentEnv, execArgv: [] });
+ agent.on('message', function (message) {
++ if (!Array.isArray(message.consoleProcessList)) {
++ return;
++ }
+ clearTimeout(timeout);
+ resolve(message.consoleProcessList);
+ });
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index f579bfa8a5a..d244cfee891 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -107,6 +107,7 @@ patchedDependencies:
[email protected]: f89252c2c08dc7b3acb8415f319ebbe15fff8c9f88a64ebe1830cd5ac5c9ac40
[email protected]: 8d2e3b10eb3f52036a9a086800180ec6cebf3b75bccc5b1775117a7244d4ac45
[email protected]: 319a9ded5db49c5b5215c511a138b33f44c7ea2972eb418192e8d5342fe75ce6
+ [email protected]: f2fe901c61cde17986240002d05c172d5d0272d83ffaab8d0ebeb922763be414
[email protected]: 0579f8e4dad02bf3183d95b02620358412983c36f9bda7425dc8bcb9643b5ce2
[email protected]: 6e4339347bc5bb3c9ea67d85ff5c814058b211c5750f247aba59d07869a2e787
[email protected]: 642b47830730acff3761fe29cf54271d18b493c0070c750097850b7ea032e00c
@@ -532,7 +533,7 @@ importers:
version: 4.0.0-rc.115(patch_hash=0dfc4bb8ebd80fb3e06b91ef61346f5259517ab0f2437644fe95ae531084b1f5)
node-pty:
specifier: ^1.2.0-beta.15
- version: 1.2.0-beta.15
+ version: 1.2.0-beta.15(patch_hash=f2fe901c61cde17986240002d05c172d5d0272d83ffaab8d0ebeb922763be414)
stream-chain:
specifier: ^4.2.5
version: 4.2.5
@@ -20110,7 +20111,7 @@ snapshots:
+ [email protected](patch_hash=f2fe901c61cde17986240002d05c172d5d0272d83ffaab8d0ebeb922763be414):
dependencies:
node-addon-api: 7.1.1
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 56c740febf1..8313ab360b2 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -196,6 +196,7 @@ patchedDependencies: