algolia / instantsearch

⚑️ Libraries for building performant and instant search experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.

Home Page:https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

deserializeQueryParameters - TypeError: Cannot read properties of undefined (reading 'split')

volodymyr-strilets-mindcurv opened this issue Β· comments

πŸ› Current behavior

Unhandled Runtime Error

image

Here is the line of the error code πŸ‘‡

image

Localhost console debug

Did a quick debug and found that the result item from deserializeQueryParameters has no params key.

image

πŸ” Steps to reproduce

I have updated the libraries and this error appeared

algoliasearch: 4.20.0 > 4.21.1
instantsearch.js: 4.58.0 > 4.62.0
react-instantsearch: 7.2.0 > 7.4.1
react-instantsearch-core: 7.2.0 > 7.4.1
react-instantsearch-router-nextjs: 7.2.0 > 7.4.1

Live reproduction

πŸ’­ Expected behavior

Working code

Package version

react-instantsearch: 7.4.1, react-instantsearch-core: 7.4.1, react-instantsearch-router-nextjs: 7.4.1, instantsearch.js: 4.62.0, algoliasearch: 4.21.1

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Hm, that should indeed be made safe, however, how do you end up in a situation where params isn't in the result. Is it manually filtered out by you? If there's no params, I'm sure that the cache will not work. Safe solution would be bailing out of writing the cache altogether in that case.

Do you have a reproducible example?

We have NextJS SSR and we use hooks from react-instantsearch as they are.
I have checked the initial server state that getServerState function returns, and there is no params key.

image

Hi, could you verify that params is removed from the response fields in your index configuration? This should be under Configuration > Search behavior > Retrieved attributes:

image

On our end we'll guard against this situation in an upcoming release of InstantSearch.

@dhayab you are right, we have a custom index config where the params field was not included. After adding it, now it works.