From 577992bbe5efc05c8057f85f77427b41030cbe67 Mon Sep 17 00:00:00 2001 From: Nathan Byrd Date: Tue, 10 Oct 2023 19:33:25 +0000 Subject: [PATCH 1/2] Changes to API for node-pty --- core/archive_util.js | 4 ++-- core/door.js | 6 +++--- core/event_scheduler.js | 4 ++-- core/file_transfer.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/archive_util.js b/core/archive_util.js index a142584b..9fad1004 100644 --- a/core/archive_util.js +++ b/core/archive_util.js @@ -208,13 +208,13 @@ module.exports = class ArchiveUtil { // pty.js doesn't currently give us a error when things fail, // so we have this horrible, horrible hack: let err; - proc.once('data', d => { + proc.onData(d => { if (_.isString(d) && d.startsWith('execvp(3) failed.')) { err = Errors.ExternalProcess(`${action} failed: ${d.trim()}`); } }); - proc.once('exit', exitCode => { + proc.onExit(exitCode => { return cb( exitCode ? Errors.ExternalProcess( diff --git a/core/door.js b/core/door.js index 313adf74..3cab2b36 100644 --- a/core/door.js +++ b/core/door.js @@ -113,7 +113,7 @@ module.exports = class Door { spawnOptions ); - prePty.once('exit', exitCode => { + prePty.onExit(exitCode => { this.client.log.info( { exitCode: exitCode }, 'Door pre-command exited' @@ -165,7 +165,7 @@ module.exports = class Door { this.doorPty.onData(this.doorDataHandler.bind(this)); - this.doorPty.once('close', () => { + this.doorPty.onExit(exitCode => { return this.restoreIo(this.doorPty); }); } else if ('socket' === this.io) { @@ -178,7 +178,7 @@ module.exports = class Door { ); } - this.doorPty.once('exit', exitCode => { + this.doorPty.onExit(exitCode => { this.client.log.info({ exitCode: exitCode }, 'Door exited'); if (this.sockServer) { diff --git a/core/event_scheduler.js b/core/event_scheduler.js index 076e116f..0140a776 100644 --- a/core/event_scheduler.js +++ b/core/event_scheduler.js @@ -166,8 +166,8 @@ class ScheduledEvent { }); return cb(e); } - - proc.once('exit', exitCode => { + + proc.onExit(exitCode => { if (exitCode) { Log.warn( { eventName: this.name, action: this.action, exitCode: exitCode }, diff --git a/core/file_transfer.js b/core/file_transfer.js index 01eec9b8..37ff882c 100644 --- a/core/file_transfer.js +++ b/core/file_transfer.js @@ -489,7 +489,7 @@ exports.getModule = class TransferFileModule extends MenuModule { return this.restorePipeAfterExternalProc(); }); - externalProc.once('exit', exitCode => { + externalProc.onExit(exitCode => { this.client.log.debug( { cmd: cmd, args: args, exitCode: exitCode }, 'Process exited' From 498c4a608238b95b1ef074e8335bdc6805e3cf70 Mon Sep 17 00:00:00 2001 From: Nathan Byrd Date: Tue, 10 Oct 2023 19:43:58 +0000 Subject: [PATCH 2/2] Additional API changes --- core/archive_util.js | 2 +- core/file_transfer.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/core/archive_util.js b/core/archive_util.js index 9fad1004..5f1eff31 100644 --- a/core/archive_util.js +++ b/core/archive_util.js @@ -358,7 +358,7 @@ module.exports = class ArchiveUtil { output += data; }); - proc.once('exit', exitCode => { + proc.onExit(exitCode => { if (exitCode) { return cb( Errors.ExternalProcess(`List failed with exit code: ${exitCode}`) diff --git a/core/file_transfer.js b/core/file_transfer.js index 37ff882c..264bb97d 100644 --- a/core/file_transfer.js +++ b/core/file_transfer.js @@ -485,10 +485,6 @@ exports.getModule = class TransferFileModule extends MenuModule { } }); - externalProc.once('close', () => { - return this.restorePipeAfterExternalProc(); - }); - externalProc.onExit(exitCode => { this.client.log.debug( { cmd: cmd, args: args, exitCode: exitCode },