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

only stream page-view #37

Merged
merged 2 commits into from
Nov 30, 2023
Merged

only stream page-view #37

merged 2 commits into from
Nov 30, 2023

Conversation

phonzammi
Copy link
Member

resolve #36

Please take a look and review

Copy link
Contributor

@lourot lourot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for doing this @phonzammi. Did you also validate that now useId() produces the same ID on server and on client?

vike-react/renderer/onRenderHtml.tsx Show resolved Hide resolved
@phonzammi
Copy link
Member Author

Thanks a lot for doing this @phonzammi.

No problem

Did you also validate that now useId() produces the same ID on server and on client?

Yes, I did

@phonzammi
Copy link
Member Author

phonzammi commented Nov 30, 2023

Before moving on, I have some thing to discuss, sorry, this might be a bit long:

Below condition can bit tricky at some point:

const isSsrDisabled = !pageContext.Page
const page = isSsrDisabled ? <></> : getPageElement(pageContext)

const streamOrString = isSsrDisabled ? dangerouslySkipEscape(renderToString(page)) : await renderToStream(page, { userAgent: pageContext.userAgent })
  • !pageContext.page mean ssr disabled is true

But, we don't really check if is it stream: httpResponse.pipe(res), or not (which is : res.status(statusCode).send(body)) we actually enforces users to use ssr with streaming or no ssr at all.
That means if users created their on server.js and they use res.status(statusCode).send(body), it just won't work and they will get an error.

I don't have any fix yet, but still digging

@brillout
Copy link
Member

That is indeed a concern, I created a new ticket for it: #38. Let's tackle it in an another PR.

If this PR is LGTM for Aurelien, then I'd suggest we merge this.

@lourot lourot merged commit 4fafebf into vikejs:main Nov 30, 2023
3 checks passed
@lourot
Copy link
Contributor

lourot commented Nov 30, 2023

Published as v0.3.5

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

Successfully merging this pull request may close these issues.

useId() unusable with SSR
3 participants