MCPcopy
hub / github.com/redis/node-redis / #onSocketError

Method #onSocketError

packages/client/lib/client/socket.ts:356–377  ·  view source on GitHub ↗
(err: Error)

Source from the content-addressed store, hash-verified

354 }
355
356 #onSocketError(err: Error): void {
357 const wasReady = this.#isReady;
358 this.#isReady = false;
359 publish(CHANNELS.ERROR, () => ({
360 error: err,
361 origin: 'client',
362 internal: false,
363 clientId: this.#clientId
364 }));
365 this.emit('error', err);
366
367 if (wasReady) {
368 publish(CHANNELS.CONNECTION_CLOSED, () => ({ clientId: this.#clientId, reason: 'error', wasConnected: true }));
369 }
370
371 if (!wasReady || !this.#isOpen || typeof this.#shouldReconnect(0, err) !== 'number') return;
372
373 this.emit('reconnecting');
374 this.#connect().catch(() => {
375 // the error was already emitted, silently ignore it
376 });
377 }
378
379
380 write(iterable: Iterable<ReadonlyArray<RedisArgument>>) {

Callers 1

#createSocketMethod · 0.95

Calls 3

#shouldReconnectMethod · 0.95
#connectMethod · 0.95
publishFunction · 0.90

Tested by

no test coverage detected