Skip to content

Commit

Permalink
fix(ssr/renderToStream): A Readable object should at least implement …
Browse files Browse the repository at this point in the history
…an empty _read method.

Nor it will throw errors.

See nodejs/node#38865.

The tests passes in jest before because jest mock the global promise and causes inconsistant behavior compared with native nodejs.
jestjs/jest#11497
  • Loading branch information
07akioni committed Jun 1, 2021
1 parent 44996d1 commit 9feb4aa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/server-renderer/src/renderToStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function unrollBufferSync(buffer: SSRBuffer, stream: Readable) {
}
}

class PushSafeReadable extends Readable {
_read() {}
}

export function renderToStream(
input: App | VNode,
context: SSRContext = {}
Expand All @@ -62,7 +66,7 @@ export function renderToStream(
// provide the ssr context to the tree
input.provide(ssrContextKey, context)

const stream = new Readable()
const stream = new PushSafeReadable()

Promise.resolve(renderComponentVNode(vnode))
.then(buffer => unrollBuffer(buffer, stream))
Expand Down

0 comments on commit 9feb4aa

Please sign in to comment.