-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
renderToHTML with getServerSideProps send response instead of return html from 9.3.1 #11665
Comments
A complete reproduction is missing, please provide one. |
related to: #11525 |
Reproduction repo: https://github.com/visum/next-renderToHTML-test |
@timneutkens , as @visum provided. i have the same issue like him |
The problem as stated in the title is that the method renderToHtml is sending the response, not just rendering the HTML. I agree that the method should return the html, ence it's name. |
In case it's not clear, another complete reproduction: https://github.com/zeit/next.js/tree/canary/examples/ssr-caching |
cacheable-response.get expects a get(req, res) method signature: https://www.npmjs.com/package/cacheable-response#get Before the change: ``` curl -s -v http://localhost:3000/blog/first 2>&1 | grep HTTP/1.1 > GET /blog/first HTTP/1.1 < HTTP/1.1 404 Not Found ``` After the change: ``` curl -s -v http://localhost:3000/blog/first 2>&1 | grep HTTP/1.1 > GET /blog/first HTTP/1.1 < HTTP/1.1 200 OK ``` This is a partial fix of #12019 to make the example work. However it doesn't fix the error ``` (node:62360) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client ``` , which will need a change at server/next-server.ts See related issue: #11525 #11665
The problem appears to be in Given that |
This is the expected behavior, as pages powered by |
It makes sense that a page using The specific use case is one that the existing documentation and examples seem to indicate should be possible using At the very least, the API could make more sense. |
I've opened an issue to remove all usage of These examples will be updated with the appropriate (public API) approaches. Reiterating above: Please open an issue for the specific use case you're looking to accomplish by getting the HTML response! We're happy to entertain use cases. |
@Timer My current project heavily relies on the |
So does our project |
After carefully reading the RFC: Incremental Static Regeneration, I believe we will switch to the Incremental Static Regeneration solution later. Sorry for polluting this thread! |
If renderToHTML potentially breaks existing functionality, or isn't the intended behaviour of the function, then it might be better to create a new one like getStaticHTML instead specifically for this use case. It's unfortunate that the renderToHTML name is already taken, but if it's no longer in example code it shouldn't cause confusion going forward. |
cacheable-response.get expects a get(req, res) method signature: https://www.npmjs.com/package/cacheable-response#get Before the change: ``` curl -s -v http://localhost:3000/blog/first 2>&1 | grep HTTP/1.1 > GET /blog/first HTTP/1.1 < HTTP/1.1 404 Not Found ``` After the change: ``` curl -s -v http://localhost:3000/blog/first 2>&1 | grep HTTP/1.1 > GET /blog/first HTTP/1.1 < HTTP/1.1 200 OK ``` This is a partial fix of vercel#12019 to make the example work. However it doesn't fix the error ``` (node:62360) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client ``` , which will need a change at server/next-server.ts See related issue: vercel#11525 vercel#11665
I've a use case that I can't resolve with the current implementation. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
when upgrade from 9.3.0 to higher version, pages with renderToHtml direct send response instead of html. it work correct when using getInitialProps.
Expected behavior
rendertohtml should always return html instead of send response
The text was updated successfully, but these errors were encountered: