MCPcopy
hub / github.com/codeaashu/claude-code / connect

Function connect

src/bridge/replBridgeTransport.ts:336–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

334 return ccr.flush()
335 },
336 connect() {
337 // Outbound-only: skip the SSE read stream entirely — no inbound
338 // events to receive, no delivery ACKs to send. Only the CCRClient
339 // write path (POST /worker/events) and heartbeat are needed.
340 if (!opts.outboundOnly) {
341 // Fire-and-forget — SSETransport.connect() awaits readStream()
342 // (the read loop) and only resolves on stream close/error. The
343 // spawn-mode path in remoteIO.ts does the same void discard.
344 void sse.connect()
345 }
346 void ccr.initialize(epoch).then(
347 () => {
348 ccrInitialized = true
349 logForDebugging(
350 `[bridge:repl] v2 transport ready for writes (epoch=${epoch}, sse=${sse.isConnectedStatus() ? 'open' : 'opening'})`,
351 )
352 onConnectCb?.()
353 },
354 (err: unknown) => {
355 logForDebugging(
356 `[bridge:repl] CCR v2 initialize failed: ${errorMessage(err)}`,
357 { level: 'error' },
358 )
359 // Close transport resources and notify replBridge via onClose
360 // so the poll loop can retry on the next work dispatch.
361 // Without this callback, replBridge never learns the transport
362 // failed to initialize and sits with transport === null forever.
363 ccr.close()
364 sse.close()
365 onCloseCb?.(4091) // 4091 = init failure, distinguishable from 4090 epoch mismatch
366 },
367 )
368 },
369 }
370}
371

Callers

nothing calls this directly

Calls 6

logForDebuggingFunction · 0.85
initializeMethod · 0.65
errorMessageFunction · 0.50
connectMethod · 0.45
isConnectedStatusMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected