Skip to content

Commit 90e9b44

Browse files
committed
add a timeout to the cloud social provider SSH connection
1 parent 7c15ec9 commit 90e9b44

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cloud/social/provider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const STORAGE_KEY = 'cloud-social-contacts';
2626
const ADMIN_USERNAME = 'giver';
2727
const REGULAR_USERNAME = 'getter';
2828

29+
// Timeout for establishing an SSH connection.
30+
const CONNECT_TIMEOUT_MS = 10000;
31+
2932
// Credentials for accessing a cloud instance.
3033
// The serialised, base64 form is distributed amongst users.
3134
// TODO: add (private) keys, for key-based auth
@@ -450,6 +453,7 @@ class Connection {
450453
host: this.invite_.host,
451454
port: SSH_SERVER_PORT,
452455
username: this.invite_.user,
456+
readyTimeout: CONNECT_TIMEOUT_MS,
453457
// Remaining fields only for type-correctness.
454458
tryKeyboard: false,
455459
debug: undefined
@@ -464,6 +468,7 @@ class Connection {
464468

465469
return new Promise<void>((F, R) => {
466470
this.client_.on('ready', () => {
471+
// TODO: set a timeout here, too
467472
this.setState_(ConnectionState.ESTABLISHING_TUNNEL);
468473
this.client_.forwardOut(
469474
// TODO: since we communicate using the stream, what does this mean?

0 commit comments

Comments
 (0)