Skip to content

Commit

Permalink
Fix static result being piped (#34111)
Browse files Browse the repository at this point in the history
We need to check if the render result is dynamic or not, before using `pipe`.
  • Loading branch information
shuding committed Feb 8, 2022
1 parent df29561 commit b5d757e
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/next/server/web-server.ts
Expand Up @@ -150,14 +150,20 @@ export default class NextWebServer extends BaseServer {
): Promise<void> {
// @TODO
const writer = res.transformStream.writable.getWriter()
options.result.pipe({
write: (chunk: Uint8Array) => writer.write(chunk),
end: () => writer.close(),
destroy: (err: Error) => writer.abort(err),
cork: () => {},
uncork: () => {},
// Not implemented: on/removeListener
} as any)

if (options.result.isDynamic()) {
options.result.pipe({
write: (chunk: Uint8Array) => writer.write(chunk),
end: () => writer.close(),
destroy: (err: Error) => writer.abort(err),
cork: () => {},
uncork: () => {},
// Not implemented: on/removeListener
} as any)
} else {
res.body(await options.result.toUnchunkedString())
}

res.send()
}
protected async runApi() {
Expand Down

0 comments on commit b5d757e

Please sign in to comment.