handle websocket construction exceptions
This commit is contained in:
parent
807ecff471
commit
8702fda651
10
app/api.js
10
app/api.js
|
@ -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));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue