Skip to content

Commit 2b732bd

Browse files
committed
fix: don't show error multiple times when lost connection to SSH tunnel
1 parent 53a284e commit 2b732bd

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

client/actions.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import _ from 'lodash';
88
const actions = {
99
connect(config) {
1010
return dispatch => {
11+
let sshErrorThrown = false
1112
if (config.ssh) {
1213
dispatch({ type: 'updateConnectStatus', data: 'SSH connecting...' });
1314
const conn = new Client();
@@ -25,26 +26,26 @@ const actions = {
2526
});
2627
})
2728
.on('error', err => {
29+
sshErrorThrown = true
2830
dispatch({ type: 'disconnect' });
2931
alert(`SSH Error: ${err.message}`);
3032
});
3133

3234
try {
35+
const connectionConfig = {
36+
host: config.sshHost,
37+
port: config.sshPort || 22,
38+
username: config.sshUser
39+
}
3340
if (config.sshKey) {
34-
conn.connect({
35-
host: config.sshHost,
36-
port: config.sshPort || 22,
37-
username: config.sshUser,
41+
conn.connect(Object.assign(connectionConfig, {
3842
privateKey: config.sshKey,
3943
passphrase: config.sshKeyPassphrase
40-
});
44+
}));
4145
} else {
42-
conn.connect({
43-
host: config.sshHost,
44-
port: config.sshPort || 22,
45-
username: config.sshUser,
46+
conn.connect(Object.assign(connectionConfig, {
4647
password: config.sshPassword
47-
});
48+
}));
4849
}
4950
} catch (err) {
5051
dispatch({ type: 'disconnect' });
@@ -98,7 +99,9 @@ const actions = {
9899
});
99100
redis.once('end', function () {
100101
dispatch({ type: 'disconnect' });
101-
alert('Redis Error: Connection failed');
102+
if (!sshErrorThrown) {
103+
alert('Redis Error: Connection failed');
104+
}
102105
});
103106
}
104107
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"redux-thunk": "^1.0.0",
4747
"reselect": "^2.0.0",
4848
"sortablejs": "^1.4.1",
49-
"ssh2": "^0.4.12",
49+
"ssh2": "^0.5.4",
5050
"url-loader": "^0.5.7"
5151
},
5252
"devDependencies": {

0 commit comments

Comments
 (0)