@@ -94,12 +94,9 @@ export abstract class QueryExecutorBase implements QueryExecutor {
9494 }
9595 abortSignal ?. addEventListener ( 'abort' , abortListener )
9696
97- // might have already abort before adding the listener.
98- if ( abortSignal . aborted ) {
99- abortListener ( )
100- }
101-
10297 try {
98+ assertNotAborted ( abortSignal , 'aborted before query execution' )
99+
103100 const queryPromise = connection . executeQuery ( compiledQuery , {
104101 cancelable : true ,
105102 } )
@@ -128,6 +125,7 @@ export abstract class QueryExecutorBase implements QueryExecutor {
128125 transformPromise ,
129126 ] )
130127
128+ // aborted.
131129 if ( ! transformedResult ) {
132130 transformPromise . catch ( ( ) => {
133131 // noop
@@ -187,6 +185,8 @@ export abstract class QueryExecutorBase implements QueryExecutor {
187185 let asyncIterator : AsyncIterableIterator < QueryResult < R > > | undefined
188186
189187 try {
188+ assertNotAborted ( abortSignal , 'aborted before query streaming' )
189+
190190 asyncIterator = connection . streamQuery ( compiledQuery , chunkSize , {
191191 cancelable : true ,
192192 } )
@@ -195,6 +195,8 @@ export abstract class QueryExecutorBase implements QueryExecutor {
195195 const controlConnectionProvider = this . provideConnection . bind ( this )
196196
197197 while ( true ) {
198+ assertNotAborted ( abortSignal , 'aborted during query streaming' )
199+
198200 const nextPromise = asyncIterator . next ( )
199201
200202 const result = await Promise . race ( [ abortPromise , nextPromise ] )
@@ -235,8 +237,6 @@ export abstract class QueryExecutorBase implements QueryExecutor {
235237 }
236238
237239 yield transformedResult
238-
239- assertNotAborted ( abortSignal , 'aborted during query streaming' )
240240 }
241241 } finally {
242242 release ( )
0 commit comments