handle websocket construction exceptions

This commit is contained in:
Danny Coates 2019-08-09 11:47:44 -07:00
parent 807ecff471
commit 8702fda651
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
1 changed files with 7 additions and 5 deletions

View File

@ -146,11 +146,13 @@ export async function setPassword(id, owner_token, keychain) {
} }
function asyncInitWebSocket(server) { function asyncInitWebSocket(server) {
return new Promise(resolve => { return new Promise((resolve, reject) => {
try {
const ws = new WebSocket(server); const ws = new WebSocket(server);
ws.onopen = () => { ws.addEventListener('open', () => resolve(ws), { once: true });
resolve(ws); } catch (e) {
}; reject(new ConnectionError(false));
}
}); });
} }