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

Function captureUnderlyingSocket

packages/client/lib/client/socket.spec.ts:91–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89
90 describe('write', () => {
91 function captureUnderlyingSocket() {
92 const original = net.createConnection;
93 const captured: { socket?: net.Socket } = {};
94 const target = net as unknown as { createConnection: unknown };
95 target.createConnection = (...args: unknown[]) => {
96 const s = (original as unknown as (...a: unknown[]) => net.Socket).apply(net, args);
97 captured.socket = s;
98 return s;
99 };
100 return {
101 captured,
102 restore() {
103 target.createConnection = original;
104 }
105 };
106 }
107
108 async function withConnectedSocket(
109 fn: (socket: RedisSocket, underlying: net.Socket) => Promise<void>

Callers 1

withConnectedSocketFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected