MCPcopy Index your code
hub / github.com/TanStack/router / pumpJSON

Function pumpJSON

packages/start-server-core/src/frame-protocol.ts:144–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

142
143 // Pump JSON stream (streamId 0)
144 const pumpJSON = async () => {
145 const reader = jsonStream.getReader()
146 cancelReaders.push(() => {
147 // Catch async rejection - reader may already be released
148 reader.cancel().catch(() => {})
149 })
150 try {
151 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
152 while (true) {
153 const { done, value } = await reader.read()
154 // Check cancelled after await - flag may have changed while waiting
155 if (cancelled) break
156 if (done) break
157 safeEnqueue(encodeJSONFrame(value))
158 }
159 } catch (error) {
160 // JSON stream error - fatal, error the whole response
161 safeError(error)
162 } finally {
163 reader.releaseLock()
164 checkComplete()
165 }
166 }
167
168 // Pump a single raw stream with its streamId
169 const pumpRawStream = async (

Callers 1

startFunction · 0.85

Calls 7

checkCompleteFunction · 0.85
safeEnqueueFunction · 0.70
encodeJSONFrameFunction · 0.70
safeErrorFunction · 0.70
getReaderMethod · 0.65
catchMethod · 0.65
cancelMethod · 0.65

Tested by

no test coverage detected