Deferred loader data and the stream end marker ($_TSR.e()) are lost when serialisation finishes before the HTML is processed.
pnpm install
npx playwright install chromium
pnpm test:bug # ✗ FAILS — scripts dropped
pnpm test:fix # ✓ PASSES — scripts presentWe set up 10 deferred server calls that resolve in the route loader.
Bug:
- Fast-exit path (this repro): stream closes synchronously before the queued microtask injects scripts.
- Main streaming path: cleanup runs before the queued microtask injects scripts.
Result: HTML looks correct but seroval $R promises never resolve.
Four changes in @tanstack/router-core (see patches/):
ssr-server.js: MakeScriptBuffer.enqueue()andliftBarrier()synchronous (removequeueMicrotask)ssr-server.js: ExposeflushScripts()onserverSsrtransformStreamWithRouter.js: CalltakeBufferedHtml()aftersetRenderFinished()in the fast-exit pathtransformStreamWithRouter.js: CallflushScripts()intryFinish()and moveliftScriptBarrier()afterflushPendingRouterHtml()