* Finish only when app done and serialization complete.
()
| 323 | * Finish only when app done and serialization complete. |
| 324 | */ |
| 325 | function tryFinish() { |
| 326 | if (isAppRendering || !serializationFinished) return |
| 327 | if (cleanedUp || isStreamClosed) return |
| 328 | |
| 329 | if (serializationTimeoutHandle !== undefined) { |
| 330 | clearTimeout(serializationTimeoutHandle) |
| 331 | serializationTimeoutHandle = undefined |
| 332 | } |
| 333 | |
| 334 | // Flush any remaining bytes in the TextDecoder |
| 335 | const decoderRemainder = textDecoder.decode() |
| 336 | |
| 337 | if (leftover) safeEnqueue(leftover) |
| 338 | if (decoderRemainder) safeEnqueue(decoderRemainder) |
| 339 | flushPendingRouterHtml() |
| 340 | if (pendingClosingTags) safeEnqueue(pendingClosingTags) |
| 341 | |
| 342 | safeClose() |
| 343 | cleanup() |
| 344 | } |
| 345 | |
| 346 | // Safety net: cleanup even if consumer never reads |
| 347 | const lifetimeMs = opts?.lifetimeMs ?? DEFAULT_LIFETIME_TIMEOUT_MS |
no test coverage detected