ssh-client-wrapper 3.4.2 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/util.js +15 -6
- package/package.json +1 -1
package/lib/util.js
CHANGED
|
@@ -402,13 +402,18 @@ export const sendPty = async (pty, message, logger, label)=>{
|
|
|
402
402
|
};
|
|
403
403
|
|
|
404
404
|
/**
|
|
405
|
-
*
|
|
405
|
+
* release what node-pty (ConPTY) leaves behind when a pty has exited (win32 only).
|
|
406
406
|
*
|
|
407
|
-
* node-pty
|
|
408
|
-
* The headless conhost.exe of the pty stays alive as long as
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
*
|
|
407
|
+
* node-pty never frees these two resources of a pty, neither when the child exits nor in kill():
|
|
408
|
+
* - the write end of the console input pipe. The headless conhost.exe of the pty stays alive as long as it is open,
|
|
409
|
+
* so every pty leaks one conhost.exe until the node process ends.
|
|
410
|
+
* - the worker thread which drains the console output pipe (ConoutConnection). It is stopped by dispose(),
|
|
411
|
+
* which only kill() calls. Every pty leaks a thread and its V8 isolate (about 10 MB).
|
|
412
|
+
* After about 1600 ptys the system runs out of resources
|
|
413
|
+
* (rsync.exe fails with 0xC000012D / 0xC0000142, node dies with "Out of memory" or "Cannot launch conpty").
|
|
414
|
+
* kill() is not used because it forks a node process per call and may send process.kill() to a recycled PID.
|
|
415
|
+
* dispose() waits one second for the remaining output before it stops the worker.
|
|
416
|
+
* This touches private fields of node-pty; it does nothing for fields which are not there.
|
|
412
417
|
* @param {object} pty - pty object returned by node-pty spawn()
|
|
413
418
|
* @param {string} [platform] - platform name (injectable for tests)
|
|
414
419
|
*/
|
|
@@ -420,6 +425,10 @@ export const releasePty = (pty, platform = process.platform)=>{
|
|
|
420
425
|
if (inSocket && !inSocket.destroyed && typeof inSocket.destroy === "function") {
|
|
421
426
|
inSocket.destroy();
|
|
422
427
|
}
|
|
428
|
+
const conout = pty?._agent?._conoutSocketWorker;
|
|
429
|
+
if (conout && typeof conout.dispose === "function") {
|
|
430
|
+
conout.dispose();
|
|
431
|
+
}
|
|
423
432
|
};
|
|
424
433
|
|
|
425
434
|
/**
|