fix: swallow error if socket has already been closed (#22934)

* Swallow error if socket has already been closed

* fix: log error
This commit is contained in:
marty-mcflai 2022-02-04 12:21:58 +01:00 committed by GitHub
parent 812b2fff04
commit f73b470ec0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -4110,7 +4110,16 @@ export class Connection {
this._rpcWebSocketConnected = false;
this._rpcWebSocketIdleTimeout = setTimeout(() => {
this._rpcWebSocketIdleTimeout = null;
this._rpcWebSocket.close();
try {
this._rpcWebSocket.close();
} catch (err) {
// swallow error if socket has already been closed.
if (err instanceof Error) {
console.log(
`Error when closing socket connection: ${err.message}`,
);
}
}
}, 500);
}
return;