algolia / algolia/instantsearch
Cannot read properties of null (reading 'hits')
- Dominant language
- TypeScript
- Stars
- 4.1k
- Forks
- 554
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 51
Description
### 🐛 Current behavior
We see that on Sentry we get a lot of the error "Cannot read properties of null (reading 'hits')".

It's hard to investigate for us as the stack trace leads us from `../../../../node_modules/instantsearch.js/es/connectors/autocomplete/connectAutocomplete.js in indices at line 63:84` to `../../../../node_modules/instantsearch.js/es/lib/utils/defer.js in progress at line 18:16`.
Our dependencies are:
```
"dependencies": {
"algoliasearch": "^4.22.1",
"react-instantsearch": "^7.5.5",
"react-instantsearch-nextjs": "0.2.4",
"search-insights": "^2.13.0"
},
```
This project is not using nextjs, but we are in a monorepo and so are sharing some packages. We are just importing from `react-instantsearch` for things like `useInfiniteHits`, `useHits`, `useRefinementList`, the `Configure` component.
We have about 26 files using react-instantsearch so I'm happy to share some code examples although it's hard for us to know _which_ part is causing the issue. So I wanted to open this issue incase it is a library bug. Happy to try and work through to understand if it's userland or not.
### 🔍 Steps to reproduce
1. Use react-instantsearch
2. See this error reported in Sentry
### Live reproduction
n/a
### 💭 Expected behavior
No error is thrown
### Package version
react-instantsearch@7.5.5
### Operating system
_No response_
### Browser
_No response_
### Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Start by tracing the reported stack entries in instantsearch.js/es/connectors/autocomplete/connectAutocomplete.js and instantsearch.js/es/lib/utils/defer.js. Reproduce the null `hits` error with react-instantsearch@7.5.5; done means identifying whether the cause is in the library or userland and documenting a reliable reproduction or resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react
- Domain
- frontend, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100