#community-help

Handling Exceptions with Typesense.js

TLDR Carl has problems handling typesense.js exceptions. Jason suggests handling it via InstantSearch and a feature request for the hooks library could expose the issue.

Powered by Struct AI

2

9
17mo
Solved
Join the chat
Jul 26, 2022 (17 months ago)
Carl
Photo of md5-b4b5ae6f21ade3ef3d7824c4b63090c3
Carl
08:57 AM
How should I gracefully handle exceptions like this from typesense.js? Error boundaries in React don't seem to work, and I can't find any kind of onError type of callbacks. Edit: I'm using the typesense instantsearch adapter, so not just typesense.js directly
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:17 PM
This needs to be handled via InstantSearch. Do the solutions in this thread work: https://github.com/algolia/react-instantsearch/issues/1144
Carl
Photo of md5-b4b5ae6f21ade3ef3d7824c4b63090c3
Carl
02:19 PM
Nope, I found that earlier and tried multiple ways to create a react error boundary, but I think something may be catching it, or it's event driven in which case the boundary won't catch it.

There is the chance I did it completely wrong of course, and if you think it should have worked, I can try again.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:33 PM
I haven’t tried this out myself, so I’m not sure if this works… But did you specifically try the 2nd code snippet here: https://github.com/algolia/react-instantsearch/issues/1144#issuecomment-378939730

with connectStateResults?
Carl
Photo of md5-b4b5ae6f21ade3ef3d7824c4b63090c3
Carl
03:37 PM
We've moved to the hooks version, which doesn't seem to have an option for that connector. As in, I couldn't find a hook for it, and I can't seem to see a connector in https://github.com/algolia/instantsearch.js/tree/master/src/connectors to make our own hook 😐

Though this isn't a typesense problem, so I don't expect you to answer that. Just thought maybe the typesense adapter is somehow not re-throwing the error properly. Especially since in the first issue you link to, the more recent comment he is making use of typesense-instantsearch-adapter too
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:39 PM
> Just thought maybe the typesense adapter is somehow not re-throwing the error properly.
I suspected this too… But I do re-throw any errors here: https://github.com/typesense/typesense-instantsearch-adapter/blob/3ac546dbe91d3f3ff5f392d39e7f2e3fcf5bdec0/src/TypesenseInstantsearchAdapter.js#L40
03:41
Jason
03:41 PM
> We’ve moved to the hooks version, which doesn’t seem to have an option for that connector. As in, I couldn’t find a hook for it,
May be this could be a feature request for the hooks lib to expose

1

Carl
Photo of md5-b4b5ae6f21ade3ef3d7824c4b63090c3
Carl
03:41 PM
Yeh I saw that too earlier when I was checking the typesense source 😅

Don't worry about it though, I think the hooks should really expose an "error" state as it did before with react-instantsearch. I was basically trying to work around it using error boundaries.
03:42
Carl
03:42 PM
Yeh for sure, though I think one was already there. I'll have a check again.

Cheers for the investigation though man

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Issue with Typesense Instantsearch and Upgrading to React 18

Carl experienced problems updating packages for a project. VIVEK suggested disabling reactStrictMode, while Jason insisted on downgrading to React 17 due to compatibility issues. Carl eventually found a workaround.

6
17mo
Solved

Connecting React Instant Search with Typesense Adapter

KARTHICK sought help with an error when using Typesense Adapter for React Instant Search. Jason advised substituting import statements. After uninstalling the react-instantsearch-dom package, KARTHICK resolved the issue.

1

10
6mo
Solved

Issues with Typesense Frontend Search Integration

Akash experienced issues integrating Typesense into their frontend search, particularly with their search box. Jason guided them to troubleshoot, eventually identifying the issue to be with react-instantsearch-dom and suggesting a downgrade to react 17, which resolved the issue.

2

52
14mo
Solved

Implementing State Export Feature Using Typesense InstantSearch.js on Node.js Backend

Kyle needed help passing search state to backend for implementing an "Export" feature, while using Typesense InstantSearch. Jason provided multiple solutions including advice on using Typesense InstantSearch adapter. The issue was resolved after some iteration.

1

10
28mo
Solved

Implementing Search Suggestion/Autocomplete Functionality in Typesense

Denis needed advice on implementing search suggestions in Typesense. Jason provided a solution for fetching after 3+ letters. However, questions on design pattern and passing hooks remain unanswered.

1

4
21mo