Repository navigation
feat(storage): accept an AbortSignal in vector and analytics bucket methods - #2906
kavishkartha05 wants to merge 1 commit into
Conversation
…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.
|
No actionable comments were generated in the recent review. Summary
Change: Feature Merge Risk:
|
🔍 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.
parameters?: VectorFetchParametersargument onsupabase.storage.vectors:createBucket,getBucket,listBuckets,deleteBucket.from(bucket):createIndex,listIndexes.from(bucket).index(name):putVectors,getVectors,listVectors,queryVectors,deleteVectorsVectorBucketApi,VectorIndexApiandVectorDataApiclassesparameters?: FetchParametersargument oncreateBucket,listBucketsanddeleteBucket, the type the other storage-js methods use.parametersis passed to the existingpost/get/removehelpers, which already forward it tofetch, so no fetch plumbing changed.VectorFetchParameterswas already exported but not used by any method.{ data: null, error }whereerroris aStorageUnknownError(StorageVectorsUnknownErrorby name for vectors) with theAbortErrorasoriginalError(or throws it afterthrowOnError()).@param parametersline on each of the 14 methods.Deferred:
.from(bucket).getIndexand.from(bucket).deleteIndexThese two take only
indexNamebut override base methods that take(vectorBucketName, indexName). A second positionalparametersargument would be in the same position as the base'sindexName: string, and TypeScript rejects the override (TS2416). This needs a maintainer decision, so I left both unchanged. The options I see:VectorBucketScopewrap aVectorIndexApiinstead of extending it, so its methods are free to take their own arguments.VectorBucketScopewould then no longer be aninstanceof VectorIndexApi.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
queryVectorsor a largeputVectorsbatch could not be aborted. This follows #2898 and #2904, which add the same argument forupload,updateanduploadToSignedUrl.Closes #2905
📸 Screenshots/Examples
🔄 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,headersand, where there is one,body.📋 Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formatting📝 Additional notes
Tests are in a new file,
test/storageVectorsAnalyticsSignal.test.ts. For each of the 14 methods it checks that:fetch;These are unit tests only, with a fetch stand-in. The local test stack has
[storage.vector]and[storage.analytics]set toenabled = falseintest/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:docsanddocs:jsonpass.Overlap with #2782: it also edits
putVectors,listVectorsanddeleteVectorsinVectorDataApi.ts. A local merge of the two branches conflicts in those three methods, because #2782 moves the input validation intohandleOperationand this PR adds theparametersargument on neighboring lines. Resolving it means keeping both changes. I'm happy to rebase on whichever lands first.