Skip to content

fix: Change from ReadWriteStream to ReadableStream #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions chakra-ui/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { PassThrough } from "stream";
import createEmotionCache from "@emotion/cache";
import { CacheProvider as EmotionCacheProvider } from "@emotion/react";
import createEmotionServer from "@emotion/server/create-instance";
import type { AppLoadContext, EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import {AppLoadContext, createReadableStreamFromReadable, EntryContext} from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";
Expand Down Expand Up @@ -51,14 +50,14 @@ const handleBotRequest = (
onAllReady: () => {
const reactBody = new PassThrough();
const emotionServer = createEmotionServer(emotionCache);

const bodyWithStyles = emotionServer.renderStylesToNodeStream();
reactBody.pipe(bodyWithStyles);

const stream = createReadableStreamFromReadable(reactBody);
responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(bodyWithStyles, {
new Response(stream, {
headers: responseHeaders,
status: didError ? 500 : responseStatusCode,
}),
Expand Down Expand Up @@ -102,10 +101,11 @@ const handleBrowserRequest = (
const bodyWithStyles = emotionServer.renderStylesToNodeStream();
reactBody.pipe(bodyWithStyles);

const stream = createReadableStreamFromReadable(reactBody);
responseHeaders.set("Content-Type", "text/html");

resolve(
new Response(bodyWithStyles, {
new Response(stream, {
headers: responseHeaders,
status: didError ? 500 : responseStatusCode,
}),
Expand Down