Skip to content

feat(storage): accept an AbortSignal in vector and analytics bucket methods - #2906

Open
kavishkartha05 wants to merge 1 commit into
supabase:masterfrom
kavishkartha05:feat/storage-vectors-analytics-signal
Open

kavishkartha05 wants to merge 1 commit into
supabase:masterfrom
kavishkartha05:feat/storage-vectors-analytics-signal

Conversation

@kavishkartha05

Copy link
Copy Markdown

🔍 Description

Lets callers cancel Storage vector and analytics bucket requests with an AbortSignal.

What changed?

This covers 14 of the 16 public vector and analytics methods.

  • Vectors: an optional trailing parameters?: VectorFetchParameters argument on
    • supabase.storage.vectors: createBucket, getBucket, listBuckets, deleteBucket
    • .from(bucket): createIndex, listIndexes
    • .from(bucket).index(name): putVectors, getVectors, listVectors, queryVectors, deleteVectors
    • and on all 13 methods of the base VectorBucketApi, VectorIndexApi and VectorDataApi classes
  • Analytics: an optional trailing parameters?: FetchParameters argument on createBucket, listBuckets and deleteBucket, the type the other storage-js methods use.
  • parameters is passed to the existing post/get/remove helpers, which already forward it to fetch, so no fetch plumbing changed. VectorFetchParameters was already exported but not used by any method.
  • An aborted request is handled like any other failed fetch in storage-js; it returns { data: null, error } where error is a StorageUnknownError (StorageVectorsUnknownError by name for vectors) with the AbortError as originalError (or throws it after throwOnError()).
  • JSDoc: a @param parameters line on each of the 14 methods.

Deferred: .from(bucket).getIndex and .from(bucket).deleteIndex

These two take only indexName but override base methods that take (vectorBucketName, indexName). A second positional parameters argument would be in the same position as the base's indexName: string, and TypeScript rejects the override (TS2416). This needs a maintainer decision, so I left both unchanged. The options I see:

  1. Leave them without a signal for now and change the base signatures in v3 so the scoped methods can add the argument.
  2. Have VectorBucketScope wrap a VectorIndexApi instead of extending it, so its methods are free to take their own arguments. VectorBucketScope would then no longer be an instanceof VectorIndexApi.
  3. Let the scoped methods also accept an object as their only argument, getIndex(indexName | { indexName, signal }). This type-checks as an override, but it adds a second calling style for one pair of methods.

I asked about this in #2905 and can follow up once there is a preference.

Why was this change needed?

None of these methods could be cancelled, so a slow queryVectors or a large putVectors batch could not be aborted. This follows #2898 and #2904, which add the same argument for upload, update and uploadToSignedUrl.

Closes #2905

📸 Screenshots/Examples

const controller = new AbortController()
setTimeout(() => controller.abort(), 5000)

const { data, error } = await supabase.storage.vectors
  .from('embeddings')
  .index('documents')
  .queryVectors({ queryVector: { float32: embedding }, topK: 5 }, { signal: controller.signal })

🔄 Breaking changes

  • This PR contains no breaking changes

The new argument is optional and comes last. Calls without it send the same request as before; a test checks that the fetch init still has only method, headers and, where there is one, body.

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run pnpm nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

📝 Additional notes

Tests are in a new file, test/storageVectorsAnalyticsSignal.test.ts. For each of the 14 methods it checks that:

  • the signal reaches fetch;
  • an already-aborted signal returns an abort error;
  • aborting mid-request returns an abort error, not the late response;
  • calls without the argument are unchanged.

These are unit tests only, with a fetch stand-in. The local test stack has [storage.vector] and [storage.analytics] set to enabled = false in test/supabase/config.toml (noted there as hosted-platform only), so there is no server to run an integration test against.

Locally: nx test:storage storage-js, build, nx format:check, lint:docs and docs:json pass.

Overlap with #2782: it also edits putVectors, listVectors and deleteVectors in VectorDataApi.ts. A local merge of the two branches conflicts in those three methods, because #2782 moves the input validation into handleOperation and this PR adds the parameters argument on neighboring lines. Resolving it means keeping both changes. I'm happy to rebase on whichever lands first.

…ethods

Add an optional trailing `parameters` argument to the vector bucket,
index and data methods (`VectorFetchParameters`) and to the analytics
`createBucket`, `listBuckets` and `deleteBucket` (`FetchParameters`). It
is passed to the existing `post`/`get`/`remove` helpers, which already
forward it to fetch, so a caller can cancel these requests.

`VectorBucketScope.getIndex` and `deleteIndex` are unchanged: a second
positional argument there would clash with the `indexName` argument of
the base methods they override.

Calls without the new argument send the same request as before.
@kavishkartha05
kavishkartha05 requested review from a team as code owners November 24, 2026 20:44
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Storage analytics and vector operations now accept optional fetch parameters, including support for abort signals to cancel requests.
  • Tests
    • Added coverage for aborting requests and for preserving existing request behavior when fetch parameters are omitted.

Vector and analytics storage methods now accept optional fetch parameters and pass them to their requests. Vector scoped methods retain automatic bucket and index scoping. Tests cover signal forwarding, aborts before and during requests, and calls without parameters.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant StorageVectorsClient
  participant VectorDataApi
  participant vectorsApi.post
  participant fetch
  Caller->>StorageVectorsClient: Call a vector operation with parameters
  StorageVectorsClient->>VectorDataApi: Forward operation options and parameters
  VectorDataApi->>vectorsApi.post: Send request and parameters
  vectorsApi.post->>fetch: Forward signal with request
Loading

Assessment against linked issues

Objective Addressed Explanation
Add optional fetch parameters to the specified vector and analytics methods and forward them to requests [#2905] ✅
Confirm signals reach fetch, aborted requests return wrapped abort errors, and calls without parameters retain expected request behavior [#2905] ✅

Suggested labels: storage-js

Change: Feature

Merge Risk: Minimal · up to 81f7a

This adds optional request-cancellation parameters to the vector and analytics storage methods. Existing calls behave as before, so the risk of merging is minimal. The scoped getIndex and deleteIndex methods intentionally remain without the new argument.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d96ff06-b1b9-4093-8924-d5fb226aa859
Commits

Reviewing files that changed from the base of the PR and between 840843d and 81f7a61.

Files selected for processing: 6

  • packages/core/storage-js/src/packages/StorageAnalyticsClient.ts
  • packages/core/storage-js/src/packages/StorageVectorsClient.ts
  • packages/core/storage-js/src/packages/VectorBucketApi.ts
  • packages/core/storage-js/src/packages/VectorDataApi.ts
  • packages/core/storage-js/src/packages/VectorIndexApi.ts
  • packages/core/storage-js/test/storageVectorsAnalyticsSignal.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

This branch has not been deployed

No deployments
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.

storage-js: vector and analytics bucket methods take no AbortSignal

1 participant