algolia / algoliasearch-client-javascript

⚡️ A fully-featured and blazing-fast JavaScript API client to interact with Algolia.
https://www.algolia.com/doc/api-client/javascript/getting-started/
MIT License
1.33k stars 222 forks source link

[bug]: TypeError: Cannot read properties of undefined (reading 'transporter') #1549

Closed sefai closed 2 months ago

sefai commented 2 months ago

Description

I've updated algoliasearch to 5.3.0 and other packages as well, below is the error I get.

Client

Search

Version

"algoliasearch": "^5.3.0", "instantsearch.js": "^4.74.0","react-instantsearch": "^7.13.0","@algolia/requester-fetch": "^5.3.0"

Relevant log output

<ref *1> TypeError: Cannot read properties of undefined (reading 'transporter')
    at search (file:///algolia_remix_project/node_modules/algoliasearch/dist/lite/builds/node.js:243:21)
    at file:///algolia_remix_project/node_modules/instantsearch.js/es/lib/utils/hydrateSearchClient.js:71:27
    at Object.get (file:///algolia_remix_project/node_modules/@algolia/client-common/dist/common.esm.js:185:21)
    at client.search (file:///algolia_remix_project/node_modules/instantsearch.js/es/lib/utils/hydrateSearchClient.js:67:48)
    at Object.search (file:///algolia_remix_project/node_modules/instantsearch.js/es/lib/server.js:26:21)
    at AlgoliaSearchHelper._search (/algolia_remix_project/node_modules/algoliasearch-helper/src/algoliasearch.helper.js:1565:8)
    at AlgoliaSearchHelper.searchOnlyWithDerivedHelpers (/algolia_remix_project/node_modules/algoliasearch-helper/src/algoliasearch.helper.js:167:8)
    at waitForResults (file:///algolia_remix_project/node_modules/instantsearch.js/es/lib/server.js:29:37)
    at file:///algolia_remix_project/node_modules/react-instantsearch-core/dist/es/server/getServerState.js:85:12
    at async eval (/algolia_remix_project/app/routes/_test.$parent.$category.tsx:78:23)
    at async Object.callRouteLoader (/algolia_remix_project/node_modules/@remix-run/server-runtime/dist/data.js:59:16)
    at async /algolia_remix_project/node_modules/@remix-run/router/dist/router.cjs.js:4683:21
    at async callLoaderOrAction (/algolia_remix_project/node_modules/@remix-run/router/dist/router.cjs.js:4748:16)
    at async Promise.all (index 2)
    at async callDataStrategyImpl (/algolia_remix_project/node_modules/@remix-run/router/dist/router.cjs.js:4623:17)
    at async callDataStrategy (/algolia_remix_project/node_modules/@remix-run/router/dist/router.cjs.js:4111:19)
    at async loadRouteData (/algolia_remix_project/node_modules/@remix-run/router/dist/router.cjs.js:4086:19)
    at async queryImpl (/algolia_remix_project/node_modules/@remix-run/router/dist/router.cjs.js:3931:20)
    at async Object.query (/algolia_remix_project/node_modules/@remix-run/router/dist/router.cjs.js:3824:18)
    at async handleDocumentRequest (/algolia_remix_project/node_modules/@remix-run/server-runtime/dist/server.js:267:15)
    at async requestHandler (/algolia_remix_project/node_modules/@remix-run/server-runtime/dist/server.js:160:18)
    at async /algolia_remix_project/node_modules/@remix-run/dev/dist/vite/cloudflare-proxy-plugin.js:70:25 {
  error: [Circular *1]
}
coyotefather commented 2 months ago

I get this as well; I do not get it with 4.24.0.

"next": "^14.2.8",
"react": "^18.3.1",
"react-instantsearch": "^7.13.0",
"react-instantsearch-nextjs": "^0.3.10",
Haroenv commented 2 months ago

Seems like you might be hitting different cases. Do you have a reproduction available with which code and what scenario this throws?

sefai commented 2 months ago

Hello @Haroenv,

I don't think this needs a reproduction, if you update "algoliasearch" to "5.3.0" in SSR example with Remix or SSR example with Next.js you will see the error.

Regards,

juan-calle commented 2 months ago

Hi, I can confirm this issue is also happening on

"algoliasearch": "^5.2.5"

working fine on

"algoliasearch": "5.1.1",
kamami commented 2 months ago

Same issue with "algoliasearch": "^5.3.0"

Haroenv commented 2 months ago

I can reproduce and am looking into the solution, of course in the mean time don't hesitate to use v4 or 5.1.1

coyotefather commented 2 months ago

With my NextJS app I get a different error with 5.1.1.

TypeError: (0 , algoliasearch__WEBPACK_IMPORTED_MODULE_1__.default) is not a function

This might be something with my particular app or setup, though.

coyotefather commented 2 months ago

Actually, the above error was because of how I was importing algoliasearch in the component. Once I fixed that I received the original error again with 5.1.1. Maybe this is specific to react-instantsearch-nextjs since that is still experimental.