@@ -94,12 +94,9 @@ export abstract class QueryExecutorBase implements QueryExecutor {
94
94
}
95
95
abortSignal ?. addEventListener ( 'abort' , abortListener )
96
96
97
- // might have already abort before adding the listener.
98
- if ( abortSignal . aborted ) {
99
- abortListener ( )
100
- }
101
-
102
97
try {
98
+ assertNotAborted ( abortSignal , 'aborted before query execution' )
99
+
103
100
const queryPromise = connection . executeQuery ( compiledQuery , {
104
101
cancelable : true ,
105
102
} )
@@ -128,6 +125,7 @@ export abstract class QueryExecutorBase implements QueryExecutor {
128
125
transformPromise ,
129
126
] )
130
127
128
+ // aborted.
131
129
if ( ! transformedResult ) {
132
130
transformPromise . catch ( ( ) => {
133
131
// noop
@@ -187,6 +185,8 @@ export abstract class QueryExecutorBase implements QueryExecutor {
187
185
let asyncIterator : AsyncIterableIterator < QueryResult < R > > | undefined
188
186
189
187
try {
188
+ assertNotAborted ( abortSignal , 'aborted before query streaming' )
189
+
190
190
asyncIterator = connection . streamQuery ( compiledQuery , chunkSize , {
191
191
cancelable : true ,
192
192
} )
@@ -195,6 +195,8 @@ export abstract class QueryExecutorBase implements QueryExecutor {
195
195
const controlConnectionProvider = this . provideConnection . bind ( this )
196
196
197
197
while ( true ) {
198
+ assertNotAborted ( abortSignal , 'aborted during query streaming' )
199
+
198
200
const nextPromise = asyncIterator . next ( )
199
201
200
202
const result = await Promise . race ( [ abortPromise , nextPromise ] )
@@ -235,8 +237,6 @@ export abstract class QueryExecutorBase implements QueryExecutor {
235
237
}
236
238
237
239
yield transformedResult
238
-
239
- assertNotAborted ( abortSignal , 'aborted during query streaming' )
240
240
}
241
241
} finally {
242
242
release ( )
0 commit comments