File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -946,6 +946,19 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
946
946
947
947
rowStream = pumpify . obj ( [ requestStream , chunkTransformer , toRowStream ] ) ;
948
948
949
+ // Retry on "received rst stream" errors
950
+ const isRstStreamError = ( error : ServiceError ) : boolean => {
951
+ if ( error . code === 13 && error . message ) {
952
+ const error_message = ( error . message || '' ) . toLowerCase ( ) ;
953
+ return (
954
+ error . code === 13 &&
955
+ ( error_message . includes ( 'rst_stream' ) ||
956
+ error_message . includes ( 'rst stream' ) )
957
+ ) ;
958
+ }
959
+ return false ;
960
+ } ;
961
+
949
962
rowStream
950
963
. on ( 'error' , ( error : ServiceError ) => {
951
964
rowStream . unpipe ( userStream ) ;
@@ -959,7 +972,7 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
959
972
numConsecutiveErrors ++ ;
960
973
if (
961
974
numConsecutiveErrors <= maxRetries &&
962
- RETRYABLE_STATUS_CODES . has ( error . code )
975
+ ( RETRYABLE_STATUS_CODES . has ( error . code ) || isRstStreamError ( error ) )
963
976
) {
964
977
const backOffSettings =
965
978
options . gaxOptions ?. retry ?. backoffSettings ||
Original file line number Diff line number Diff line change @@ -1429,6 +1429,28 @@ describe('Bigtable/Table', () => {
1429
1429
done ( ) ;
1430
1430
} ) ;
1431
1431
} ) ;
1432
+
1433
+ it ( 'should retry received rst stream errors' , done => {
1434
+ const rstStreamError = new Error ( 'Received Rst_stream' ) as ServiceError ;
1435
+ rstStreamError . code = 13 ;
1436
+ emitters = [
1437
+ ( ( stream : Duplex ) => {
1438
+ stream . emit ( 'error' , rstStreamError ) ;
1439
+ } ) as { } as EventEmitter ,
1440
+ ( ( stream : Duplex ) => {
1441
+ stream . end ( [ { key : 'a' } ] ) ;
1442
+ } ) as { } as EventEmitter ,
1443
+ ] ;
1444
+
1445
+ const options = {
1446
+ keys : [ 'a' ] ,
1447
+ } ;
1448
+
1449
+ callCreateReadStream ( options , ( ) => {
1450
+ assert . strictEqual ( reqOptsCalls . length , 2 ) ;
1451
+ done ( ) ;
1452
+ } ) ;
1453
+ } ) ;
1432
1454
} ) ;
1433
1455
} ) ;
1434
1456
You can’t perform that action at this time.
0 commit comments