handle websocket construction exceptions
This commit is contained in:
parent
807ecff471
commit
8702fda651
12
app/api.js
12
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) => {
|
||||||
const ws = new WebSocket(server);
|
try {
|
||||||
ws.onopen = () => {
|
const ws = new WebSocket(server);
|
||||||
resolve(ws);
|
ws.addEventListener('open', () => resolve(ws), { once: true });
|
||||||
};
|
} catch (e) {
|
||||||
|
reject(new ConnectionError(false));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue