Skip to content

Commit

Permalink
add pipeTrough
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Feb 28, 2024
1 parent 3514ba5 commit a0faf01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions integration-test/vite-streaming/server.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import express from "express";
import { renderToReadableStream } from "react-dom/server.edge";
import { Writable } from "node:stream";
import { readFile } from "node:fs/promises";

// Constants
const isProduction = process.env.NODE_ENV === "production";
const port = process.env.PORT || 5173;
const base = process.env.BASE || "/";
const ABORT_DELAY = 10000;

// Create http server
const app = express();
Expand Down Expand Up @@ -48,7 +46,6 @@ console.log({
assets,
});

// based on https://github.com/facebook/react/blob/9cdf8a99edcfd94d7420835ea663edca04237527/fixtures/fizz/server/render-to-stream.js
app.use("*", async (req, res) => {
// The new wiring is a bit more involved.
res.socket.on("error", (error) => {
Expand Down Expand Up @@ -77,7 +74,10 @@ app.use("*", async (req, res) => {
})
);

await pipeReaderToResponse(reactStream.getReader(), res);
await pipeReaderToResponse(
reactStream.pipeThrough(transformStream).getReader(),
res
);
});

async function pipeReaderToResponse(reader, res) {
Expand Down
1 change: 0 additions & 1 deletion integration-test/vite-streaming/src/Transport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { WrapApolloProvider } from "@apollo/client-react-streaming";
import { buildManualDataTransport } from "@apollo/client-react-streaming/experimental-manual-transport";
import { renderToString } from "react-dom/server";
import React, { useContext } from "react";
import { Transform } from "node:stream";

const InjectionContext = React.createContext<
(callback: () => React.ReactNode) => void
Expand Down

0 comments on commit a0faf01

Please sign in to comment.