fix: preserve reconnect after local socket errors

This commit is contained in:
2026-09-05 18:09:56 +08:00
parent a3cd74d316
commit 9ad477f474
2 changed files with 63 additions and 6 deletions
@@ -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?.();
};
}