fix: preserve reconnect after local socket errors
This commit is contained in:
+15
-1
@@ -65,7 +65,21 @@ export class LocalLoginTransport implements Transport {
|
||||
};
|
||||
socket.onerror = (event) => {
|
||||
if (this.socket !== socket) return;
|
||||
this.stopWithFault(event);
|
||||
try {
|
||||
this.options.record({ kind: 'transport-error', data: event });
|
||||
} catch (error) {
|
||||
this.stopWithFault(error);
|
||||
throw error;
|
||||
}
|
||||
if (this.socket !== socket || this.generation !== generation) return;
|
||||
// Invalidate before close: browsers may dispatch close after error.
|
||||
this.socket = null;
|
||||
try {
|
||||
socket.close();
|
||||
} catch (error) {
|
||||
this.options.onFault(error);
|
||||
throw error;
|
||||
}
|
||||
if (this.generation === generation) this.closeCallback?.();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user