MCPcopy Index your code
hub / github.com/codeaashu/claude-code / drainFlushGate

Function drainFlushGate

src/bridge/replBridge.ts:848–869  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

846 // Called after writeBatch completes (or fails) so queued messages
847 // are sent in order after the historical messages.
848 function drainFlushGate(): void {
849 const msgs = flushGate.end()
850 if (msgs.length === 0) return
851 if (!transport) {
852 logForDebugging(
853 `[bridge:repl] Cannot drain ${msgs.length} pending message(s): no transport`,
854 )
855 return
856 }
857 for (const msg of msgs) {
858 recentPostedUUIDs.add(msg.uuid)
859 }
860 const sdkMessages = toSDKMessages(msgs)
861 const events = sdkMessages.map(sdkMsg => ({
862 ...sdkMsg,
863 session_id: currentSessionId,
864 }))
865 logForDebugging(
866 `[bridge:repl] Drained ${msgs.length} pending message(s) after flush`,
867 )
868 void transport.writeBatch(events)
869 }
870
871 // Teardown reference — set after definition below. All callers are async
872 // callbacks that run after assignment, so the reference is always valid.

Callers 1

wireTransportFunction · 0.70

Calls 5

logForDebuggingFunction · 0.85
toSDKMessagesFunction · 0.85
writeBatchMethod · 0.80
endMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected