renderToReadableStream streams a pending root boundary as fallback + script even after allReady, so react-email output is broken (0.3.1)

Abierto
#182 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
nodejs, react, typescript
Área
backend, web-dev

Línea de trabajo

Reproduce with the issue's script under NODE_ENV=production, rendering the same tree through react-dom/server and @tanstack/redact/server, and compare the HTML. Start at the renderToReadableStream server export and trace where suspense boundaries flush: the <!--$?0--> marker, $RC(0) script and hidden S:0 div must not appear once allReady resolves. Done means this repro emits one inline document matching React's output, with no fallback script or hidden segment.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

When everything under the outermost Suspense boundary suspends, Redact's renderToReadableStream still sends that boundary's fallback, the boundary script and a hidden <div id="S:0"> holding the real content, even when the caller waits for allReady before reading. React writes the finished content inline once allReady has resolved.

This breaks every email rendered by react-email under Redact. Its render() wraps the email in <Suspense>, waits for allReady, then reads the stream as a static document. Its Tailwind component suspends while it compiles, so the whole email is pending when the shell flushes. The resulting HTML has a <script>, an empty <div id="B:0">, and the <!DOCTYPE>/<html> nested inside a hidden <div>. Mail clients run no scripts, and a sandboxed preview <iframe> without allow-scripts shows a blank page.

Reproduction
import { Suspense, use } from 'react'
import { renderToReadableStream } from 'react-dom/server'

const data = new Promise((resolve) => setTimeout(() => resolve('Body text'), 20))

function Document() {
  return (
    <html lang="en">
      <head>
        <meta charSet="utf-8" />
        <title>Hello</title>
      </head>
      <body>
        <p>{use(data)}</p>
      </body>
    </html>
  )
}

const stream = await renderToReadableStream(
  <Suspense>
    <Document />
  </Suspense>,
  { progressiveChunkSize: Number.POSITIVE_INFINITY },
)
await stream.allReady
console.log(await new Response(stream).text())

Run with Node 26, NODE_ENV=production, once with React's react-dom/server and once with @tanstack/redact/server.

React 19.3.1:

<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><title>Hello</title></head><body><!--$--><!--html--><!--head--><!--body--><p>Body text</p><!--/$--></body></html>

Redact 0.3.1 (boundary runtime script shortened):

<!--$?0--><div id="B:0"></div><!--/$--><script>(function(){ /* $RH, $RC, $RL, $RB ... */ })();</script><div hidden id="S:0"><!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>Hello</title></head><body><p>Body text</p></body></html></div><script>$RC(0)</script>

A related difference shows up even when nothing is pending at flush time: with the same outer <Suspense>, Redact writes <!--$0--> before <!DOCTYPE html> and <!--/$--> after </html>, so comments sit outside the document element. React writes nothing before the doctype.

Expected

Once allReady has resolved before the first read, every completed boundary is written inline in place, with no fallback, no boundary script and no hidden segment, as React does. This is the pattern static renderers rely on (react-email, and anything else that awaits allReady to get a complete document).

Environment

@tanstack/redact 0.3.1, React 19.3.1, react-email 6.11.16 (@react-email/render 2.3.1), Node 26.13.1.

Lenguaje dominante
TypeScript
Estrellas
640
Forks
32
Merge medio
1 h 15 min
PR fusionados (30 d)
7

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TanStack/redact

Todos los issues de TanStack/redact

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.