Unverified Commit b5d757e0 authored by Shu Ding's avatar Shu Ding Committed by GitHub

Fix static result being piped (#34111)

We need to check if the render result is dynamic or not, before using `pipe`.
parent df29561a
......@@ -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() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment