generated from forge-42/open-source-stack
-
-
Notifications
You must be signed in to change notification settings - Fork 19
Labels
bugSomething isn't workingSomething isn't workinginvestigatingI'm looking at this!I'm looking at this!waiting feedback on PR
Description
I was trying to implement this using Bun, but when navigating to a page that uses deferred data, the request is closed prematurely and the stream never reaches the client. At first, I thought it was an issue with Bun, but I tested it with Node and encountered the same problem.
You can reproduce this issue using the latest version of React Router by following the installation steps in the repository.
Just in case it's relevant, here's my package.json:
{
"name": "bun-hono-bug",
"private": true,
"type": "module",
"scripts": {
"build": "react-router build",
"dev": "react-router dev",
"start": "react-router-serve ./build/server/index.js",
"typecheck": "react-router typegen && tsc"
},
"dependencies": {
"@react-router/node": "^7.5.1",
"@react-router/serve": "^7.5.1",
"isbot": "^5.1.17",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router": "^7.5.1",
"react-router-hono-server": "*"
},
"devDependencies": {
"@react-router/dev": "^7.5.1",
"@tailwindcss/vite": "^4.0.0",
"@types/node": "^20",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
"react-router-devtools": "^1.1.0",
"tailwindcss": "^4.0.0",
"typescript": "^5.7.2",
"vite": "^5.4.11",
"vite-tsconfig-paths": "^5.1.4"
}
}and whatver route with a deferred data
import { Suspense } from "react";
import { Await, useLoaderData } from "react-router";
import { Welcome } from "../welcome/welcome";
import type { Route } from "./+types/home";
export function meta({}: Route.MetaArgs) {
return [
{ title: "New React Router App" },
{ name: "description", content: "Welcome to React Router!" },
];
}
export async function loader() {
return {
data: new Promise((resolve) => {
setTimeout(() => {
resolve({ message: "Hello, world!" });
}, 5000);
}),
};
}
export default function Home() {
const { data } = useLoaderData<typeof loader>();
return (
<>
<Welcome />
<Suspense fallback={<div>Loading...</div>}>
<Await resolve={data}>{(data) => <div>{data.message}</div>}</Await>
</Suspense>
</>
);
}
the bug is
Error: The destination stream closed early.
at PassThrough.<anonymous> (/home/erik/Personales/bun-hono-bug/node_modules/react-dom/cjs/react-dom-server.node.development.js:7662:24)
at PassThrough.emit (node:events:519:28)
at emitCloseNT (node:internal/streams/destroy:147:10)
at processTicksAndRejections (node:internal/process/task_queues:81:21)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinginvestigatingI'm looking at this!I'm looking at this!waiting feedback on PR