[react-instantsearch-nextjs] - NextJS App Router double server side calls #6457
-
We are seeing that there are 2 exactly the same api calls are happening on SSR. We see this in Vercel and we also see this in Algolia Realtime Monitoring. Example of a double request happening at the exact same time:
Versions:
We have a very normal hook based implementation, 1 virtual search-box, and we use initial filters for our PLPs. What is the cause that on server level 2 api calls are executed? We don't have additional client side calls when SSR'ing the page. So that is not the issue. Or if anyone knows a better way to debug this locally please let me know. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Indeed, we were just made knowledge of this and I've been working on a solution. For now a workaround is manually enabling a cache that you clear on every page load (to prevent memory pressure or leaks). The implementation for app router can be seen here: https://github.com/algolia/instantsearch/pull/6456/files#diff-22a1bfe50b37796a54cfc70812b508ee6c4938bf92ecdb3a3b36dedfa1541237 note that this PR also includes a fix that ensures the user token is always consistent, so you may want to cherry-pick that fix in your site already Hope that helps! |
Beta Was this translation helpful? Give feedback.
Indeed, we were just made knowledge of this and I've been working on a solution. For now a workaround is manually enabling a cache that you clear on every page load (to prevent memory pressure or leaks).
The implementation for app router can be seen here: https://github.com/algolia/instantsearch/pull/6456/files#diff-22a1bfe50b37796a54cfc70812b508ee6c4938bf92ecdb3a3b36dedfa1541237
note that this PR also includes a fix that ensures the user token is always consistent, so you may want to cherry-pick that fix in your site already
Hope that helps!