Skip to content

Conversation

lerouxb
Copy link
Contributor

@lerouxb lerouxb commented May 16, 2022

No description provided.

@lerouxb lerouxb force-pushed the reconnect-ssh-tunnel branch from b330869 to c750e78 Compare May 16, 2022 12:20

this.sshClient = new SshClient();

this.sshClient.on('close', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mscdex/ssh2#491 (comment)

Yes, the 'close' event will always be called when a socket is closed, whether a connection was ended gracefully or closed due to error. Speaking of which, you'll want to add an 'error' event handler for the connection in case of errors, to prevent the process from dying by default.

}

debug('creating SSH connection');
const ac = new AbortController();
Copy link
Contributor Author

@lerouxb lerouxb May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AbortController allows us to cancel listening to the 'error' and 'ready' events when the Promise.race resolves or rejects. A bit minor in the bigger scheme of things, but would technically be a leak?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! didn't know once accepted a signal

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s only supported in Node.js 15+, I think this might not be working yet? But I guess it’s fine to leave it like this and see it start working when we upgrade Electron :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we have an abortcontroller polyfill, but yeah - probably doesn't touch events.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fine this way - the leaks were already there and they are super minor. You're only going to make so many ssh tunnels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I just removed the AbortController stuff for now because it was spiralling out and out. It requires jsdom so I'd have to systematically move more and more packages onto our react mocha config so that the polyfill is there when it uses ssh-tunnel.

@lerouxb lerouxb force-pushed the reconnect-ssh-tunnel branch from c750e78 to 4c929c1 Compare May 16, 2022 12:26
@lerouxb lerouxb force-pushed the reconnect-ssh-tunnel branch from 4c929c1 to 825b6a9 Compare May 16, 2022 12:28
@lerouxb lerouxb marked this pull request as ready for review May 17, 2022 11:40
Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Only one comment on the tests :)

@lerouxb lerouxb merged commit f816ddc into main May 17, 2022
@lerouxb lerouxb deleted the reconnect-ssh-tunnel branch May 17, 2022 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants