Skip to content

Bug: renderToPipeableStream is missing in Bun exports #33612

Open
@kravetsone

Description

@kravetsone

React version: 19.10.0

Steps To Reproduce

  1. Run under Bun and Node and see the export differense without a reason
import { createServer } from "node:http";
import { renderToPipeableStream } from "react-dom/server"; // in bun it uses server.bun and in node server.node

function App() {
  return <div>Hello World</div>;
}

function handleRequest(res) {
  // ... in your server handler ...
  const stream = renderToPipeableStream(<App />, {
    onShellReady() {
      res.statusCode = 200;
      res.setHeader("Content-type", "text/html");
      stream.pipe(res);
    },
    // ...
  });
}

const http = createServer((req, res) => handleRequest(res));

http.listen(3000, () => {
  console.log("Server is running on port 3000");
});
> bun .\a.tsx
1 | (function (entry, fetcher)
              ^
SyntaxError: Export named 'renderToPipeableStream' not found in module '...\node_modules\react-dom\server.bun.js'.
      at loadAndEvaluateModule (1:11)

Bun v1.2.17-canary.50+41d10ed01 (Windows x64)
> bunx tsx .\a.tsx
Server is running on port 3000

as we can see it really missing here: https://github.com/facebook/react/blob/main/packages/react-dom/src/server/ReactDOMFizzServerBun.js

It works fine if you force .node export:

import { createServer } from "node:http";
import { renderToPipeableStream } from "react-dom/server.node";

function App() {
  return <div>Hello World</div>;
}

function handleRequest(res) {
  // ... in your server handler ...
  const stream = renderToPipeableStream(<App />, {
    onShellReady() {
      res.statusCode = 200;
      res.setHeader("Content-type", "text/html");
      stream.pipe(res);
    },
    // ...
  });
}

const http = createServer((req, res) => handleRequest(res));

http.listen(3000, () => {
  console.log("Server is running on port 3000");
});

The current behavior

Export named 'renderToPipeableStream' not found in module '...\node_modules\react-dom\server.bun.js'.

It brokes react-router usage on Bun

The expected behavior

It should works as in node export

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions