Properly handle connection timeout on unauthenticated websocket

This commit is contained in:
Fedor Indutny 2021-07-29 09:25:21 -07:00 committed by GitHub
parent 8cadc40975
commit d4a30a0165
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -407,7 +407,17 @@ export class SocketManager extends EventListener {
});
this.unauthenticated = process;
const unauthenticated = await this.unauthenticated.getResult();
let unauthenticated: WebSocketResource;
try {
unauthenticated = await this.unauthenticated.getResult();
} catch (error) {
window.log.info(
'SocketManager: failed to connect unauthenticated socket ' +
` due to error: ${Errors.toLogFormat(error)}`
);
this.dropUnauthenticated(process);
throw error;
}
window.log.info('SocketManager: connected unauthenticated socket');
@ -540,8 +550,10 @@ export class SocketManager extends EventListener {
{
abort() {
if (resource) {
window.log.warn(`SocketManager closing socket ${path}`);
resource.close(3000, 'aborted');
} else {
window.log.warn(`SocketManager aborting connection ${path}`);
clearTimeout(timer);
client.abort();
}