Skip to content

Commit

Permalink
fix: content truncated because response end is called too early
Browse files Browse the repository at this point in the history
  • Loading branch information
jamyouss committed Dec 5, 2020
1 parent 59088ba commit ecbde66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
5 changes: 1 addition & 4 deletions src/server.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ test("serveFragment with pipeStream option", async () => {
callback(undefined, "<div>hi there</div>");
},
});
input.pipe(
transformer,
{ end: false }
);
input.pipe(transformer);
return transformer;
},
})
Expand Down
12 changes: 2 additions & 10 deletions src/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,9 @@ export async function serveFragment(
);

const removeReactRootStream = new RemoveReactRoot();
stream.pipe(
removeReactRootStream,
{ end: false }
);
stream.pipe(removeReactRootStream);

const lastStream: NodeJS.ReadableStream = options.pipeStream ? options.pipeStream(removeReactRootStream) : removeReactRootStream;

lastStream.pipe(
res,
{ end: false }
);

stream.on("end", () => res.end());
lastStream.pipe(res);
}

0 comments on commit ecbde66

Please sign in to comment.