Skip to content

feat(multisearch): Add AbortSignal Support to MultiSearch Operations#297

Merged
jasonbosco merged 2 commits intotypesense:masterfrom
tharropoulos:abort-multi
Jun 18, 2025
Merged

feat(multisearch): Add AbortSignal Support to MultiSearch Operations#297
jasonbosco merged 2 commits intotypesense:masterfrom
tharropoulos:abort-multi

Conversation

@tharropoulos
Copy link
Copy Markdown
Collaborator

TLDR

Add AbortSignal support to multisearch with test coverage

Change Summary

Added Features:

  1. In src/Typesense/MultiSearch.ts:
    • AbortSignal support through SearchOptions parameter in perform() method
    • Pass abort signal to underlying API call for request cancellation
    • Updated method signatures to use SearchOptions instead of cache-only options

Code Changes:

  1. In src/Typesense/MultiSearch.ts:
    • Import updates: Added SearchOptions type import, converted to type-only imports
    • Method signature changes: Updated perform() overloads to accept SearchOptions
    • Parameter handling: Refactored options destructuring to use SearchOptions
    • API integration: Added abortSignal parameter to requestWithCache.perform()

Test Coverage:

  1. New Test File test/multisearch-abort.spec.ts:
    • Immediate rejection test: Verifies requests are rejected when AbortSignal is already aborted
    • Cancel token creation test: Ensures proper axios cancel token setup when AbortSignal is provided
    • Event listener management tests: Confirms abort event listeners are added and cleaned up correctly
    • Normal operation test: Validates multisearch works without abort signal
    • Streaming support test: Tests abort functionality with conversation streaming
    • Error handling test: Verifies abort signal works with error responses

- Add tests for `AbortSignal` support in multisearch operations
- Test immediate rejection when signal is already aborted
- Test cancel token creation and event listener management
- Test streaming requests with abort functionality
- Test error handling with abort signal integration
@jasonbosco jasonbosco merged commit 53064f1 into typesense:master Jun 18, 2025
1 check passed
@jasonbosco
Copy link
Copy Markdown
Member

Published in v2.1.0-9

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

Successfully merging this pull request may close these issues.

2 participants