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) {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const ws = new WebSocket(server);
|
||||
ws.onopen = () => {
|
||||
resolve(ws);
|
||||
};
|
||||
ws.addEventListener('open', () => resolve(ws), { once: true });
|
||||
} catch (e) {
|
||||
reject(new ConnectionError(false));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue