@@ -115,6 +115,7 @@ class Result implements Promise<QueryResult> {
115
115
private _connectionHolder : connectionHolder . ConnectionHolder
116
116
private _keys : string [ ] | null
117
117
private _summary : ResultSummary | null
118
+ private _error : Error | null
118
119
private _watermarks : { high : number ; low : number }
119
120
120
121
/**
@@ -141,6 +142,7 @@ class Result implements Promise<QueryResult> {
141
142
this . _connectionHolder = connectionHolder || EMPTY_CONNECTION_HOLDER
142
143
this . _keys = null
143
144
this . _summary = null
145
+ this . _error = null
144
146
this . _watermarks = watermarks
145
147
}
146
148
@@ -154,8 +156,10 @@ class Result implements Promise<QueryResult> {
154
156
}
155
157
*/
156
158
keys ( ) : Promise < string [ ] > {
157
- if ( this . _keys != null ) {
159
+ if ( this . _keys !== null ) {
158
160
return Promise . resolve ( this . _keys )
161
+ } else if ( this . _error !== null ) {
162
+ return Promise . reject ( this . _error )
159
163
}
160
164
return new Promise ( ( resolve , reject ) => {
161
165
this . _streamObserverPromise
@@ -179,8 +183,10 @@ class Result implements Promise<QueryResult> {
179
183
*
180
184
*/
181
185
summary ( ) : Promise < ResultSummary > {
182
- if ( this . _summary != null ) {
186
+ if ( this . _summary !== null ) {
183
187
return Promise . resolve ( this . _summary )
188
+ } else if ( this . _error !== null ) {
189
+ return Promise . reject ( this . _error )
184
190
}
185
191
return new Promise ( ( resolve , reject ) => {
186
192
this . _streamObserverPromise
@@ -405,6 +411,7 @@ class Result implements Promise<QueryResult> {
405
411
// and result can't bee consumed any further; call the original onError callback after that
406
412
this . _connectionHolder . releaseConnection ( ) . then ( ( ) => {
407
413
replaceStacktrace ( error , this . _stack )
414
+ this . _error = error
408
415
onErrorOriginal . call ( observer , error )
409
416
} )
410
417
}
@@ -431,7 +438,9 @@ class Result implements Promise<QueryResult> {
431
438
* @returns {void }
432
439
*/
433
440
_cancel ( ) : void {
434
- this . _streamObserverPromise . then ( o => o . cancel ( ) )
441
+ if ( this . _summary === null && this . _error === null ) {
442
+ this . _streamObserverPromise . then ( o => o . cancel ( ) )
443
+ }
435
444
}
436
445
437
446
/**
0 commit comments