Skip to content

Infinite Page Loading Next.js when no connection to search server #6525

Open
@dwin0

Description

@dwin0

🐛 Current behavior

Next.js version: 15.0.4

I'm using InstantSearchNext together with Typesense (typesense-instantsearch-adapter). Everything works fine, except when there's no connection to the self hosted Typesense server. In this case, the following things happen:

  • Server side: A huge nested stack trace is displayed with this content:
    constructor: [Function: AxiosError] { from: [Function (anonymous)] },
    toJSON: [Function: toJSON],
    [AggregateError: ] { code: 'ECONNREFUSED' }
    
  • Client side: Infinite loading screen.

Yes, this is problem is more relevant for self hosted search servers, but I would expect this behaviour to appear as well when there's a connection problem with Algolia.

🔍 Steps to reproduce

  1. Install InstantSearchNext
  2. Point the search client to a non-existing URL
  3. Open the page with SSR enabled

I tried to replicate the local setup on codesandbox, but I see a different error there.

Live reproduction

https://codesandbox.io/p/devbox/nifty-snowflake-fgxqcg?file=%2Fcomponents%2Fsearch.tsx%3A5%2C9-5%2C21

💭 Expected behavior

I would expect to see the Next.js error component being sent to the browser.

Could it be that the error is not bubbled up correctly? Or it's bubbled up, but some code is not reacting to it? I looked into this code a bit and was wondering if the reason is that the promise only resolved on "result": once('result'
https://github.com/algolia/instantsearch/blob/master/packages/react-instantsearch-nextjs/src/InitializePromise.tsx

I found this previous issue that sounds related to the current problem. The solution at that time was to adjust the error propagation logic: #5233

Thanks for any support on this issue!

Package version

[email protected] [email protected] [email protected]

Operating system

maxOS 15.2

Browser

Chrome 131

Code of Conduct

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageIssues to be categorized by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions