1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-11-13 22:54:15 +01:00

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

View File

@ -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));
}
});
}