Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated node-pty to support new node versions #489

Merged
merged 7 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .vscode/launch.json

This file was deleted.

12 changes: 6 additions & 6 deletions core/archive_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,17 @@ 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(exitEvent => {
return cb(
exitCode
? Errors.ExternalProcess(
`${action} failed with exit code: ${exitCode}`
`${action} failed with exit code: ${exitEvent.exitCode}`
)
: err
);
Expand Down Expand Up @@ -358,10 +358,10 @@ module.exports = class ArchiveUtil {
output += data;
});

proc.once('exit', exitCode => {
if (exitCode) {
proc.onExit(exitEvent => {
if (exitEvent.exitCode) {
return cb(
Errors.ExternalProcess(`List failed with exit code: ${exitCode}`)
Errors.ExternalProcess(`List failed with exit code: ${exitEvent.exitCode}`)
);
}

Expand Down
12 changes: 7 additions & 5 deletions core/door.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ module.exports = class Door {
spawnOptions
);

prePty.once('exit', exitCode => {
prePty.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.info(
{ exitCode: exitCode },
{ exitCode, signal },
'Door pre-command exited'
);
return callback(null);
Expand Down Expand Up @@ -167,7 +168,7 @@ module.exports = class Door {

this.doorPty.onData(this.doorDataHandler.bind(this));

this.doorPty.once('close', () => {
this.doorPty.onExit( (/*exitEvent*/) => {
return this.restoreIo(this.doorPty);
});
} else if ('socket' === this.io) {
Expand All @@ -180,8 +181,9 @@ module.exports = class Door {
);
}

this.doorPty.once('exit', exitCode => {
this.client.log.info({ exitCode: exitCode }, 'Door exited');
this.doorPty.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.info({ exitCode, signal }, 'Door exited');

if (this.sockServer) {
this.sockServer.close();
Expand Down
10 changes: 5 additions & 5 deletions core/event_scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ class ScheduledEvent {
return cb(e);
}

proc.once('exit', exitCode => {
if (exitCode) {
proc.onExit(exitEvent => {
if (exitEvent.exitCode) {
Log.warn(
{ eventName: this.name, action: this.action, exitCode: exitCode },
{ eventName: this.name, action: this.action, exitCode: exitEvent.exitCode },
'Bad exit code while performing scheduled event action'
);
}
return cb(
exitCode
exitEvent.exitCode
? Errors.ExternalProcess(
`Bad exit code while performing scheduled event action: ${exitCode}`
`Bad exit code while performing scheduled event action: ${exitEvent.exitCode}`
)
: null
);
Expand Down
9 changes: 3 additions & 6 deletions core/file_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,10 @@ exports.getModule = class TransferFileModule extends MenuModule {
}
});

externalProc.once('close', () => {
return this.restorePipeAfterExternalProc();
});

externalProc.once('exit', exitCode => {
externalProc.onExit(exitEvent => {
const {exitCode, signal} = exitEvent;
this.client.log.debug(
{ cmd: cmd, args: args, exitCode: exitCode },
{ cmd: cmd, args: args, exitCode, signal },
'Process exited'
);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"minimist": "^1.2.6",
"moment": "2.29.4",
"nntp-server": "3.1.0",
"node-pty": "0.10.1",
"node-pty": "1.0.0",
NuSkooler marked this conversation as resolved.
Show resolved Hide resolved
"nodemailer": "6.7.7",
"otplib": "11.0.1",
"qrcode-generator": "^1.4.4",
Expand Down
Loading