Skip to content

Commit

Permalink
Reland "fix: try to close connection on ssh close"
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelEinbinder committed May 28, 2024
1 parent 1cf5e42 commit 56d5c3a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/LogView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ Use uname -a to check whether the system is MacOS or Linux.`
this._itemToParent.set(item, parent);
this.addRetainer({item, parent});
} else {
if (this._prompt)
const promptElement = this._prompt?.render();
if (promptElement && promptElement.parentElement === this._scroller)
this._scroller.insertBefore(element, this._prompt.render());
else
this._scroller.appendChild(element);
Expand Down
20 changes: 19 additions & 1 deletion src/Shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,28 @@ export class Shell {
};
return handler;
}

_logMessageToUser(message: string) {
this.addItem(new JSLogBlock({
type: 'log',
args: [{
type: 'string',
value: message,
}],
executionContextId: -1,
timestamp: 0,
}, this.connection, this._size));
}

async _setupConnectionInner(core: ConnectionCore, args: string[], sshAddress = null) {
this._clearCache();
const connection = new JSConnection(core);
core.onclose = () => connection.didClose();
core.onclose = () => {
if (!destroyed)
this._logMessageToUser('Connection closed.');
destroy();
connection.didClose();
}
this._connectionIsDaemon.set(connection, false);
const urlForIframe = (filePath: string) => core.urlForIframe(filePath, []);
this._urlForIframeForConncetion.set(connection, urlForIframe);
Expand Down

0 comments on commit 56d5c3a

Please sign in to comment.