MCPcopy
hub / github.com/redis/node-redis / write

Method write

packages/client/lib/client/socket.ts:380–403  ·  view source on GitHub ↗
(iterable: Iterable<ReadonlyArray<RedisArgument>>)

Source from the content-addressed store, hash-verified

378
379
380 write(iterable: Iterable<ReadonlyArray<RedisArgument>>) {
381 if (!this.#socket || !this.#socket.writable) return;
382
383 this.#socket.cork();
384 try {
385 for (const args of iterable) {
386 for (const toWrite of args) {
387 this.#socket.write(toWrite);
388 }
389
390 if (this.#socket.writableNeedDrain) break;
391 }
392 } catch (err) {
393 // net.Socket.write can throw synchronously on a half-closed socket
394 // (writeAfterFIN -> EPIPE) before the 'close' event fires. The pending
395 // command has already been moved to #waitingForReply by the queue's
396 // generator, so the close handler will reject it on reconnect.
397 if (!err || (err as NodeJS.ErrnoException).code !== 'EPIPE') {
398 throw err;
399 }
400 } finally {
401 this.#socket.uncork();
402 }
403 }
404
405 async quit<T>(fn: () => Promise<T>): Promise<T> {
406 if (!this.#isOpen) {

Callers 4

#attachListenersMethod · 0.45
#writeMethod · 0.45
socket.spec.tsFile · 0.45
setupMockServerFunction · 0.45

Calls

no outgoing calls

Tested by 1

setupMockServerFunction · 0.36