Server side rendering with getRunningOperationPromises
See original GitHub issueHi
I’ve try to take a look at the ssr-experiment exemple here:
- https://github.com/JulienKode/ssr-experiments/pull/new/chore/demo
- https://codesandbox.io/s/naughty-robinson-47e9jt?file=/package.json
I’ve:
- added console log on
getRunningOperationPromises
- Create a fake long query (10s)
- try to fetch with few seconds of delay the two pages:
On the beedrill
fetch this is what I can see when displaying running promises:
{
"getPokemonByName(\"beedrill\")": {
"arg": "beedrill",
"requestId": "070QxaL_aSi7MV3VbQzDQ",
"queryCacheKey": "getPokemonByName(\"beedrill\")"
},
"getPokemonByName(\"bulbasaur\")": {
"arg": "bulbasaur",
"requestId": "FdsRw3PmBbDP5sR7-kKPe",
"queryCacheKey": "getPokemonByName(\"bulbasaur\")"
}
}
- Is it normal that we are waiting for
bulbasaur
when our page are just concern aboutbeedrill
? - Should the
runningPromises
created in the api be unique to each page and not sharing across different page ? otherwise on large scale apps this could be an issue if we are waiting for the queries of another page - Does the
runningPromises
should be isolated to each page on SSR ? - like
createListenerMiddleware
should we have acreateApiMiddleware
? Then on server side, we can have a different middleware instance for each page that does not share values
This is the debug line that I’ve added in redux:
function getRunningOperationPromises() {
console.warn("[DEBUG] RUNNING OPERATION PROMISES ", {runningQueries})
console.warn(JSON.stringify(runningQueries, null, 2))
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Server Side Rendering - Redux Toolkit
RTK Query supports Server Side Rendering (SSR) with Next.js via rehydration in combination with next-redux-wrapper.
Read more >Server-Side Rendering - Redux Toolkit Query
Server Side Rendering · Pre-fetch all queries via the initiate actions, e.g. store.dispatch(api.endpoints.getPokemonByName.initiate(name)) · Wait ...
Read more >Server-side rendering - Apollo GraphQL Docs
Server -side rendering (SSR) is a performance optimization for modern web apps. It enables you to render your app's initial state to raw...
Read more >Server-side Rendering | urql Documentation
On the server-side it's able to gather all results as they're being fetched, which can then be serialized and sent to the client....
Read more >Server-Side Rendering - Stitches.dev
How to configure server-side rendering. You can get access to the CSS string by using the getCssText function. This function is made available...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Good observation - this should be scoped per store instance. Could be difficult though as it is outside of a middleware 🤔
This will still take some time until it makes in - we’ll have to carefully weigh if and how we can break the existing implementation - since the new one would have to be
dispatched
. I know the old api was just plain wrong, but we’ll have to discuss this quite a lot.You can isntall the PR-patched package from the CodeSandbox registry in the meantime though.