Fix top level async breaks with routes that don't stream - #2280
Conversation
| log.trace('start ssr'); | ||
|
|
||
| const rscReadable = response.canStream() | ||
| const rscReadable = canStream |
There was a problem hiding this comment.
The problem starts here, the rscReadable is setup based on the initial status of streaming. But if something suspends in App.server.jsx, this will always be true. Later in the logic down below though all of a sudden response.canStream() is false. So to keep it consistent, the variable is set once and reused everywhere.
| (resp) => resp.text() | ||
| ); | ||
|
|
||
| expect(response).toContain('<meta data-flight="S2'); |
There was a problem hiding this comment.
The case where it breaks, <meta data-flight actually is embedded twice. So the value won't be S2, rather an encoded <meta data-flight
jplhomer
left a comment
There was a problem hiding this comment.
Nice find and fix 👍
But just to clarify: If you suspend in the root App component, then any calls to response.doNotStream() in route files will not be effective. Are we aligned there?
This is what we have in our documentation: https://shopify.dev/custom-storefronts/hydrogen/framework/routes#response-donotstream
Description
Fix a critical issue where a top level asynchronous request within
App.server.jsxwould break if subsequent routes attempt to disable streaming. For example:Additional context
Before submitting the PR, please make sure you do the following:
fixes #123)yarn changeset addif this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning