Skip to content
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

Client handles abort signals incorrectly in high availability configuration #251

Open
jonatansberg opened this issue Dec 12, 2024 · 1 comment

Comments

@jonatansberg
Copy link

Description

Using SearchClient with the cluster configuration suggested by the docs (both LB + nodes) together with an AbortSignal causes the client to bypass the LB and call the nodes directly if/when the signal fires.

Steps to reproduce

  • Use SearchClient in cluster configuration suggested by the docs (both LB + nodes)
  • Pass an abort controller signal in SearchOptions
let controller: AbortController | null = null;
const client = new SearchClient({
  nearestNode: { host: 'xxx.a1.typesense.net', port: 443, protocol: 'https' },
  nodes: [
    { host: 'xxx-1.a1.typesense.net', port: 443, protocol: 'https' },
    { host: 'xxx-2.a1.typesense.net', port: 443, protocol: 'https' },
    { host: 'xxx-3.a1.typesense.net', port: 443, protocol: 'https' },
  ],
  apiKey: '<API_KEY>',
  connectionTimeoutSeconds: 2
});

function search(q: string) {
  if (controller) controller.abort();
  controller = new AbortController();
  const abortSignal = controller.signal;

  client
    .collections('<collection>')
    .documents()
    .search(
      { 
        q
        // ...rest of query
      },
      { abortSignal }
    );
}

Expected Behavior

Request is aborted when signal fires.

Actual Behavior

Request is aborted, and this makes the client cycle through the nodes. Initially from the LB -> first node, and then proceeding through the nodes in order every time a request is interrupted, wrapping around to the first one at the end.

Metadata

Typesense Version: 1.8.2, 1.7.2
OS: MacOS

@jonatansberg jonatansberg changed the title Client handles abort signals incorrectly in high availability configura Client handles abort signals incorrectly in high availability configuration Dec 12, 2024
@jasonbosco
Copy link
Member

Thank you for reporting this issue.

The fix for this is now in v2.0.0-13. Could you give it a shot and let us know how it goes?

CC: @tharropoulos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants