Skip to content
Source
Sign inSign up
Open History to see the last commit

node-pty@1.2.0-beta.15.patch

55 lines2.8 KB

1diff --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 */:
17diff --git a/lib/windowsPtyAgent.js b/lib/windowsPtyAgent.js
18--- a/lib/windowsPtyAgent.js
19+++ b/lib/windowsPtyAgent.js
20@@ -218,13 +218,31 @@
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 settled = false;
29+ var finish = function (list) {
30+ if (settled) return;
31+ settled = true;
32+ clearTimeout(timeout);
33+ resolve(list);
34+ };
35+ var agent = (0, child_process_1.fork)(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()], { env: agentEnv, execArgv: [], windowsHide: true });
36 agent.on('message', function (message) {
37- clearTimeout(timeout);
38- resolve(message.consoleProcessList);
39+ if (!message || !Array.isArray(message.consoleProcessList)) {
40+ return;
41+ }
42+ finish(message.consoleProcessList);
43+ });
44+ agent.on('error', function () {
45+ finish([_this._innerPid]);
46+ });
47+ agent.on('close', function () {
48+ finish([_this._innerPid]);
49 });
50 var timeout = setTimeout(function () {
51 // Something went wrong, just send back the shell PID
52 agent.kill();
53- resolve([_this._innerPid]);
54+ finish([_this._innerPid]);
55 }, 5000);