-
Notifications
You must be signed in to change notification settings - Fork 386
In some cases there are multiple identical requests #355
Comments
Finding the root cause is a priority, as for fixing like you said it can depend on our strategy (inside RIS, or inside the helper). Still the helper could be smarter on this part (pending request, same parameter, reuse request). |
Seeing this issue as well and it's messing things up quite a bit for our analytics component. Do you guys have any plans to fix this in the near future? |
We are working on this right now, in the meantime any situations in which this occurs will help us pinpoint the issue. Can you make a reproduction on for example CodeSandbox @callmephilip ? |
@Haroenv i don't think i can provide an easily reproducible example - the app is closed source. those multiple requests seem to fire when refinements are adjusted - we are using standard RefinemnentList components from RIS, nothing funky |
A refinement list will always send two requests, one with In any case, this issue is for cases when two duplicate requests are done on every change, not just on refinementList |
I am seeing 2 requests with import { createConnector } from 'react-instantsearch';
export const connectAnalytics = createConnector({
displayName: 'AlgoliaAnalytics',
getProvidedProps(props, searchState, searchResults) {
// inspect search results here and report to GTM
return props;
},
}); |
The requests sent seem identical:
And
|
I have some questions: are you using InstantSearch in controlled mode? If yes, are you directly modifying the A temporary workaround that can be used when dealing with multiple request until we find the underlying issue is to wrap the IS component and use the |
I have finally got a chance to start looking into this in more depth and I am definitely seeing some strange behaviors. Here are a few more points that might provide additional context:
"react-instantsearch": "^4.5.1" |
I've just upgraded to |
Thanks for those information, I understand that your app is a closed source. But having a small reproduction could help us to investigate more closely the issue. You can find a template in CodeSandbox. |
@samouss you can find a mini reproduction here: https://codesandbox.io/s/jj3990ry3 To my best understanding, whenever we were trying to use a wrapped component inside the |
Thanks, it will help us a lot! I will take a look in the coming days. |
Hi @callmephilip, I looked at your example. The issue come from the Back to your example, the |
Thanks for the clarifications, Samuel. Does this effectively prohibit the usage of any wrapped components inside IS? |
No the usage of wrapper is not prohibit. What should be avoided (wrapper or not) is to pass a new reference of a prop on each render even when it doesn't change. But I hope we will get rid of this limitation in the upcoming versions. |
It seems that the latest version of react-instantsearch does not have the issue anymore. You can try this here: https://codesandbox.io/s/6opx1zk8n (based on a fork of @callmephilip example with the latest react-instantsearch version) |
Actually no React InstantSearch still have the issue. It's patched in our API Client but not in the library itself. For example users that implement a custom search client (like the one implemented by @iam4x) will still have the issue. |
We are experiencing the same issue. Is there any work around for this? |
@CodeMohan for the moment the workaround is inside the Algolia client. You can opt-in for an option that deduplicate pending requests. This behaviour is enabled by default with the version 5.2.0 of React InstantSearch. If for any reasons you can't upgrade to the v5 you can use the prop |
Thanks @samouss. We tried the second approach you suggested. It did remove the duplicate calls but experiencing other side effects. We are investigating those issues. |
I've stumbled across this myself. Recently moved from purely client rendering to SSR and was seeing duplicate requests being sent out. With the above option going into However - toggling refinements on/off/on/off results in new requests being made after each interaction, while our client-side only code was smart enough to not send identical requests out. I've done text diffs on the requests with the same refinements and the payloads are identical. Is there any update on this issue? |
Could you provide us a reproducible example? That would help to understand the issue. We provide a template to avoid you the boilerplate part. You can find it on CodeSandbox. |
note the prop is now called |
Do you have a |
I found the cause of my other issue, I was re-creating the However |
Glad to see that you solved your issue. Yes, |
this has been fixed by using algoliasearch@4 or _useRequestCache in v3 |
Do you want to request a feature or report a bug?
bug
Bug: What is the current behavior?
a single refinement (any of them) cases N requests with the exact same parameters
Bug: What is the expected behavior?
one request per exact same parameters
What is the version you are using? Always use the latest one before opening a bug issue.
4.0.10
This is visible in
As discussed with @vvo, we should deduplicate requests either at the React InstantSearch or Helper level, since this might be hard to solve otherwise.
The text was updated successfully, but these errors were encountered: