Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: ReactDOMServer.renderToReadableStream is not a function #4608

Open
1 task done
laymonage opened this issue Dec 15, 2024 · 5 comments
Open
1 task done

TypeError: ReactDOMServer.renderToReadableStream is not a function #4608

laymonage opened this issue Dec 15, 2024 · 5 comments
Labels

Comments

@laymonage
Copy link

  • Check if updating to the latest Preact version resolves the issue

Describe the bug

Hi! I'm trying to update https://github.com/giscus/giscus to the latest Preact version (10.25.2) and I got a TypeError: ReactDOMServer.renderToReadableStream is not a function when I try to load any page. Not sure how helpful it is, but here's the stack trace:

Stack trace
Server Error
TypeError: ReactDOMServer.renderToReadableStream is not a function

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
Object.renderToInitialStream
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/next/dist/server/node-web-streams-helper.js (123:27)
renderShell
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/next/dist/server/render.js (755:57)
Object.renderPage
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/next/dist/server/render.js (671:28)
Object.defaultGetInitialProps
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/next/dist/server/render.js (350:67)
CustomDocument.getInitialProps
node_modules/next/dist/pages/_document.js (19:19)
Object.<anonymous>
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/next/dist/shared/lib/utils.js (75:33)
Generator.next
<anonymous>
asyncGeneratorStep
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/@swc/helpers/lib/_async_to_generator.js (23:28)
_next
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/@swc/helpers/lib/_async_to_generator.js (12:17)
<unknown>
file:///Users/sage/Code/git/github/giscus/giscus/node_modules/@swc/helpers/lib/_async_to_generator.js (17:13)

To Reproduce

Honestly, it's probably my fault for still using Next.js that no longer supports Preact. I'm on Next.js 12.3.4 and next-plugin-preact 3.0.7, as those are the last versions that still work together.

I should probably either move on from Next.js or Preact, but I thought this could possibly a legit bug in Preact, so I'm raising this anyway. Feel free to close this if whatever caused this was intended.

For the record, this still worked fine in 10.23.2. Trying the versions between that and the latest 10.25.2, I found that it started to break in 10.24.0. I couldn't find anything in the release notes that could be related. The closest is probably #4490, but I'm not sure why a warning would cause it to crash.

Expected behavior

I expect it to work just fine, like in 10.23.2.

@JoviDeCroock
Copy link
Member

10.24.0 hasn't changed anything relating to exports https://github.com/preactjs/preact/releases/tag/10.24.0. We've also never had that export so maybe something else got upgraded?

@laymonage
Copy link
Author

I thought it might've been the case, but giscus/giscus#1576 shows that it is preact 10.24.0 (only) that caused the build to fail 😔

All the other packages (except Next.js ones) updated without issue giscus/giscus#1574.

@JoviDeCroock
Copy link
Member

That's very odd, we've never had that export in https://github.com/preactjs/preact/blob/main/compat/server.mjs#L11-L15 - kind of confused how that's possible, maybe because we updated the fake compat version Next thinks it can start leveraging the stream #4488

@rschristian
Copy link
Member

rschristian commented Dec 15, 2024

Indeed, Next sniffs out the React version and alters behavior (rather considerably) for 18.0+.

Any reason to avoid re-exporting it? Next may or may not work well with it of course, but that's a separate issue.

@JoviDeCroock
Copy link
Member

I am personally not confident in our streaming implementation atm as it's not battle tested so our issue counter might explode if we do 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants