bdy 1.22.16-dev → 1.22.18-dev

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.16-dev",
4
+ "version": "1.22.18-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -217,17 +217,18 @@ class ServerSsh extends events_1.default {
217
217
  let x11;
218
218
  let sessionClosed = false;
219
219
  let clientCloseSession = null;
220
- const closeSession = (exitCode) => {
220
+ const closeSession = () => {
221
221
  if (sessionClosed)
222
222
  return;
223
223
  sessionClosed = true;
224
224
  logger_1.default.debug('ssh close session');
225
- if (exitCode === undefined && sftp)
226
- exitCode = 0;
227
- if (exitCode !== undefined) {
228
- session.exit(exitCode);
225
+ try {
226
+ session.exit(0);
229
227
  session.end();
230
228
  }
229
+ catch {
230
+ // do nothing
231
+ }
231
232
  env = null;
232
233
  pty = null;
233
234
  x11 = null;
@@ -249,6 +250,11 @@ class ServerSsh extends events_1.default {
249
250
  client.on('close', clientCloseSession);
250
251
  session.on('close', () => closeSession());
251
252
  session.on('end', () => closeSession());
253
+ session.on('eof', () => {
254
+ // @ts-ignore fix for sftp channel not ending properly https://github.com/mscdex/ssh2/pull/1111
255
+ if (session._channel)
256
+ session._channel.end();
257
+ });
252
258
  session.on('pty', (accept, reject, info) => {
253
259
  logger_1.default.debug('ssh pty');
254
260
  logger_1.default.debug(info);
@@ -391,12 +397,6 @@ class ServerSsh extends events_1.default {
391
397
  if (!sftp && accept) {
392
398
  const sftpStream = accept();
393
399
  sftp = new sftp_1.default(sftpStream);
394
- sftpStream.on('error', () => {
395
- closeSession(1);
396
- });
397
- sftpStream.on('close', () => {
398
- closeSession(0);
399
- });
400
400
  }
401
401
  else if (reject) {
402
402
  reject();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.16-dev",
4
+ "version": "1.22.18-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {