()
| 167 | // Pumps the JSON stream, sending JSON frames |
| 168 | // JSON stream errors are fatal - they error the entire output |
| 169 | async function pumpJSON(): Promise<void> { |
| 170 | const reader = jsonStream.getReader() |
| 171 | readers.push(reader) |
| 172 | try { |
| 173 | while (!cancelled) { |
| 174 | const { done, value } = await reader.read() |
| 175 | if (done) return |
| 176 | if (!enqueue(encodeJSONFrame(value))) return |
| 177 | } |
| 178 | } catch (error) { |
| 179 | // JSON stream error is fatal - error the entire output |
| 180 | errorOutput(error) |
| 181 | throw error // Re-throw to signal failure to Promise.all |
| 182 | } finally { |
| 183 | reader.releaseLock() |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | // Pumps late stream registrations, spawning raw stream pumps as they arrive |
| 188 | async function pumpLateStreams(): Promise<Array<Promise<void>>> { |
no test coverage detected