Fix socket management for unlinkAndDisconnect

This commit is contained in:
Fedor Indutny 2021-09-15 11:44:27 -07:00 committed by GitHub
parent 039bd072ed
commit 5780c3d4b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 24 deletions

View file

@ -187,14 +187,18 @@ export class SocketManager extends EventListener {
authenticated = await process.getResult();
this.status = SocketStatus.OPEN;
} catch (error) {
strictAssert(this.authenticated === process, 'Someone stole our socket');
this.dropAuthenticated(process);
window.log.warn(
'SocketManager: authenticated socket connection failed with ' +
`error: ${Errors.toLogFormat(error)}`
);
// The socket was deliberately closed, don't follow up
if (this.authenticated !== process) {
return;
}
this.dropAuthenticated(process);
if (error instanceof HTTPError) {
const { code } = error;
@ -389,6 +393,16 @@ export class SocketManager extends EventListener {
}
}
public async logout(): Promise<void> {
const { authenticated } = this;
if (authenticated) {
authenticated.abort();
this.dropAuthenticated(authenticated);
}
this.credentials = undefined;
}
//
// Private
//