Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of null (reading 'hits') #6404

Open
1 task done
bitttttten opened this issue Oct 19, 2024 · 3 comments
Open
1 task done

Cannot read properties of null (reading 'hits') #6404

bitttttten opened this issue Oct 19, 2024 · 3 comments
Labels
triage Issues to be categorized by the team

Comments

@bitttttten
Copy link

🐛 Current behavior

We see that on Sentry we get a lot of the error "Cannot read properties of null (reading 'hits')".

Screenshot 2024-10-19 at 12 17 53

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

[email protected]

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@bitttttten bitttttten added the triage Issues to be categorized by the team label Oct 19, 2024
@Haroenv
Copy link
Contributor

Haroenv commented Oct 19, 2024

The most interesting part to reproduce would be the part where you're using connectAutocomplete. I wonder if it's possibly rendering conditionally and therefore at some timing where there's no results? It's odd because this is in a loop with the scopedResults array which therefore is definitely present, but it seems to imply that one of the results is null. Could this maybe be an adjacent index widget which is rendered conditionally as well?

We could guard for the case but I'd rather find out why results is null before, maybe something larger is wrong?

@bitttttten
Copy link
Author

What could help you here? Shall I share some more of our set up code?

@Haroenv
Copy link
Contributor

Haroenv commented Oct 21, 2024

a minimal reproduction that shows the issue is the most efficient way for us to dig down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issues to be categorized by the team
Projects
None yet
Development

No branches or pull requests

2 participants