-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Request Cancellation #112
Comments
Disregard, seems possible already using the second https://github.com/typesense/typesense-js/blob/master/src/Typesense/Documents.ts#L129-L131 |
Works with the latest version (v1.2.1) but detecting the |
This fails when passing the
update 1: This is an example on how the signal is being passed: import { useQuery } from 'react-query';
useQuery(
['search', query],
async ({ signal }) => {
if (!query.trim() || query.length < 3) {
return { query, hits: [] };
}
const omni = typesense.collections("omni").documents();
const results = await omni.search({
q: query,
query_by: "name, description, labels",
}, {
// TODO: Fix query cancelation signal in typesense
abortSignal: signal
});
return {
query,
hits: results.hits,
};
},
config
); |
Doesn't seem possible for |
Description
I'd like to be able to abort requests using the
AbortController
API...https://developer.mozilla.org/en-US/docs/Web/API/AbortController
Steps to reproduce
This is a feature request not a bug.
Expected Behavior
There'd be some way to pass an
AbortController
to each underlyingaxios
call in order to cancel an ongoing request before another is made. This not only saves resources but also helps to avoid race conditions where an older request comes back after a newer one (e.g. when typing fast).https://axios-http.com/docs/cancellation
Actual Behavior
As far as I can tell, there's no way to do this as of right now using things like
.collections(...).documents().search(...)
. I think we'd need to add an optional second argument to anything usingApiCall
Metadata
Typsense Version: SDK v0.12.1 / Server v0.22.2
OS: MacOS
The text was updated successfully, but these errors were encountered: