callback invoked multiple times for a single search


I am integrating Algolia on my ecommerce. I need to fetch asynchronously some product’s data after the search has been done.

I am using InstantSearch (v4.56.5) and I have followed this tutorial from the docs.

The problem is that my search function is invoked twice for a single search.

This is my code:

const algoliaInstantSearchClient = algoliasearch('foo', 'bar');
const originalSearch = = async (queries) => {
  const { results } = await originalSearch(queries)

  console.log("search callback invoked.")

  return { results };

In the browser console I see that search callback invoked is printed two times after a single search.

How can I fix this?
Am I using the wrong callback for my goal (fetching product’s data after search)?

I have digged in the docs and I have found that dynamic faceting (which I am using) causes an extra HTTP request to Algolia. I don’t know if this is related to my problem, but I think it’s not, because I am using a version of InstantSearch (4.56.5) where this should be fixed.