File tree Expand file tree Collapse file tree
packages/engines/src/lib/orchestrator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -372,12 +372,26 @@ export class PdfEngine<T = Blob> implements IPdfEngine<T> {
372372 { priority } ,
373373 ) ;
374374
375+ // Wire up abort: when resultTask is aborted, also abort the queue task
376+ const originalAbort = resultTask . abort . bind ( resultTask ) ;
377+ resultTask . abort = ( reason ) => {
378+ renderHandle . abort ( reason ) ; // Cancel the queue task!
379+ originalAbort ( reason ) ;
380+ } ;
381+
375382 renderHandle . wait (
376383 ( rawImageData ) => {
384+ // Check if resultTask was already aborted before encoding
385+ if ( resultTask . state . stage !== 0 /* Pending */ ) {
386+ return ;
387+ }
377388 this . encodeImage ( rawImageData , options , resultTask ) ;
378389 } ,
379390 ( error ) => {
380- resultTask . fail ( error ) ;
391+ // Only forward error if resultTask is still pending
392+ if ( resultTask . state . stage === 0 /* Pending */ ) {
393+ resultTask . fail ( error ) ;
394+ }
381395 } ,
382396 ) ;
383397
You can’t perform that action at this time.
0 commit comments