MCPcopy Index your code
hub / github.com/Effect-TS/effect / onConnection_

Function onConnection_

packages/platform-node-shared/src/NodeSocketServer.ts:70–104  ·  view source on GitHub ↗
(conn: Net.Socket)

Source from the content-addressed store, hash-verified

68 )
69 const run = yield* FiberSet.runtime(fiberSet)<R>()
70 function onConnection_(conn: Net.Socket) {
71 let error: Error | undefined
72 conn.on("error", (err) => {
73 error = err
74 })
75 pipe(
76 NodeSocket.fromDuplex(
77 Effect.acquireRelease(
78 Effect.suspend((): Effect.Effect<Net.Socket, Socket.SocketError> => {
79 if (error) {
80 return Effect.fail(new Socket.SocketGenericError({ reason: "Open", cause: error }))
81 } else if (conn.closed) {
82 return Effect.fail(
83 new Socket.SocketCloseError({
84 reason: "Close",
85 code: 1000
86 })
87 )
88 }
89 return Effect.succeed(conn)
90 }),
91 (conn) =>
92 Effect.sync(() => {
93 if (conn.closed === false) {
94 conn.destroySoon()
95 }
96 })
97 )
98 ),
99 Effect.flatMap(handler),
100 Effect.catchAllCause(reportUnhandledError),
101 Effect.provideService(NodeSocket.NetSocket, conn),
102 run
103 )
104 }
105 return yield* Effect.async<never>((_resume) => {
106 const prev = onConnection
107 onConnection = onConnection_

Callers

nothing calls this directly

Calls 3

syncMethod · 0.80
failMethod · 0.65
pipeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…