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