@@ -533,33 +533,11 @@ export class Embedder {
533533 return this . clients . length ;
534534 }
535535
536- /** FR-05: Wrap a promise with a global timeout using AbortSignal for TRUE cancellation.
537- * @param promiseFactory - A function that receives an AbortSignal and returns a promise
538- */
539- private withTimeout < T > ( promiseFactory : ( signal : AbortSignal ) => Promise < T > , label : string ) : Promise < T > {
536+ /** Wrap a single embedding operation with a global timeout via AbortSignal. */
537+ private withTimeout < T > ( promiseFactory : ( signal : AbortSignal ) => Promise < T > , _label : string ) : Promise < T > {
540538 const controller = new AbortController ( ) ;
541539 const timeoutId = setTimeout ( ( ) => controller . abort ( ) , EMBED_TIMEOUT_MS ) ;
542-
543- // Create the promise with the signal
544- const promise = promiseFactory ( controller . signal ) ;
545-
546- // Race between the original promise and timeout
547- // When timeout fires, controller.abort() will:
548- // 1. Trigger the abort event below to reject
549- // 2. If embedWithRetry received the signal, it will cancel the underlying HTTP request
550- const timeoutPromise = new Promise < never > ( ( _ , reject ) => {
551- controller . signal . addEventListener ( 'abort' , ( ) => {
552- clearTimeout ( timeoutId ) ;
553- reject ( new Error (
554- `[memory-lancedb-pro] ${ label } timed out after ${ EMBED_TIMEOUT_MS } ms`
555- ) ) ;
556- } ) ;
557- } ) ;
558-
559- return Promise . race ( [ promise , timeoutPromise ] )
560- . finally ( ( ) => {
561- clearTimeout ( timeoutId ) ;
562- } ) as Promise < T > ;
540+ return promiseFactory ( controller . signal ) . finally ( ( ) => clearTimeout ( timeoutId ) ) ;
563541 }
564542
565543 // --------------------------------------------------------------------------
@@ -586,11 +564,11 @@ export class Embedder {
586564 // --------------------------------------------------------------------------
587565
588566 async embedQuery ( text : string ) : Promise < number [ ] > {
589- return this . withTimeout ( ( signal ) => this . embedSingle ( text , this . _taskQuery , signal ) , "embedQuery" ) ;
567+ return this . withTimeout ( ( signal ) => this . embedSingle ( text , this . _taskQuery , 0 , signal ) , "embedQuery" ) ;
590568 }
591569
592570 async embedPassage ( text : string ) : Promise < number [ ] > {
593- return this . withTimeout ( ( signal ) => this . embedSingle ( text , this . _taskPassage , signal ) , "embedPassage" ) ;
571+ return this . withTimeout ( ( signal ) => this . embedSingle ( text , this . _taskPassage , 0 , signal ) , "embedPassage" ) ;
594572 }
595573
596574 // Note: embedBatchQuery/embedBatchPassage are NOT wrapped with withTimeout because
0 commit comments