fix: mark the socket as closed when receiving a close/error message (#25180)
This commit is contained in:
parent
5948b6c741
commit
e024806aa5
|
@ -4174,6 +4174,7 @@ export class Connection {
|
|||
* @internal
|
||||
*/
|
||||
_wsOnError(err: Error) {
|
||||
this._rpcWebSocketConnected = false;
|
||||
console.error('ws error:', err.message);
|
||||
}
|
||||
|
||||
|
@ -4181,6 +4182,7 @@ export class Connection {
|
|||
* @internal
|
||||
*/
|
||||
_wsOnClose(code: number) {
|
||||
this._rpcWebSocketConnected = false;
|
||||
this._rpcWebSocketGeneration++;
|
||||
if (this._rpcWebSocketHeartbeat) {
|
||||
clearInterval(this._rpcWebSocketHeartbeat);
|
||||
|
|
|
@ -518,10 +518,36 @@ describe('Subscriptions', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
describe('then having the socket connection error', () => {
|
||||
beforeEach(() => {
|
||||
stubbedSocket.emit(
|
||||
'error',
|
||||
new Error('A bad thing happened to the socket'),
|
||||
);
|
||||
});
|
||||
describe('making another subscription while disconnected', () => {
|
||||
beforeEach(() => {
|
||||
stubbedSocket.call.resetHistory();
|
||||
setupListener(spy());
|
||||
});
|
||||
it('does not issue an RPC call', () => {
|
||||
expect(stubbedSocket.call).not.to.have.been.called;
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('then having the socket connection drop unexpectedly', () => {
|
||||
beforeEach(() => {
|
||||
stubbedSocket.emit('close');
|
||||
});
|
||||
describe('making another subscription while disconnected', () => {
|
||||
beforeEach(() => {
|
||||
stubbedSocket.call.resetHistory();
|
||||
setupListener(spy());
|
||||
});
|
||||
it('does not issue an RPC call', () => {
|
||||
expect(stubbedSocket.call).not.to.have.been.called;
|
||||
});
|
||||
});
|
||||
describe('upon the socket connection reopening', () => {
|
||||
let fatalPriorUnubscribe;
|
||||
beforeEach(() => {
|
||||
|
|
Loading…
Reference in New Issue