MCPcopy Create free account
hub / github.com/Effect-TS/effect / makeSocket

Function makeSocket

packages/platform/node/src/NodeRedis.ts:50–65  ·  view source on GitHub ↗
(
  socket: NodeRedisClientOptions["socket"],
  signal: AbortSignal,
  isReady: () => boolean
)

Source from the content-addressed store, hash-verified

48}
49
50const makeSocket = (
51 socket: NodeRedisClientOptions["socket"],
52 signal: AbortSignal,
53 isReady: () => boolean
54) => {
55 return {
56 ...withSignal(socket, signal),
57 reconnectStrategy: socket?.reconnectStrategy ?? ((retries, cause) => {
58 if (!isReady()) return cause
59 if (cause instanceof SocketTimeoutError) return false
60 const jitter = Math.floor(Math.random() * 200)
61 const delay = Math.min(2 ** retries * 50, 2000)
62 return delay + jitter
63 })
64 }
65}
66
67// Destroying first leaves the abort only an untracked, still-connecting socket
68// to close, so it raises no client error.

Callers 1

NodeRedis.tsFile · 0.85

Calls 1

withSignalFunction · 0.85

Tested by

no test coverage detected