This repository was archived by the owner on Mar 26, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -946,6 +946,19 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
946946
947947 rowStream = pumpify . obj ( [ requestStream , chunkTransformer , toRowStream ] ) ;
948948
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+
949962 rowStream
950963 . on ( 'error' , ( error : ServiceError ) => {
951964 rowStream . unpipe ( userStream ) ;
@@ -959,7 +972,7 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
959972 numConsecutiveErrors ++ ;
960973 if (
961974 numConsecutiveErrors <= maxRetries &&
962- RETRYABLE_STATUS_CODES . has ( error . code )
975+ ( RETRYABLE_STATUS_CODES . has ( error . code ) || isRstStreamError ( error ) )
963976 ) {
964977 const backOffSettings =
965978 options . gaxOptions ?. retry ?. backoffSettings ||
Original file line number Diff line number Diff line change @@ -1429,6 +1429,28 @@ describe('Bigtable/Table', () => {
14291429 done ( ) ;
14301430 } ) ;
14311431 } ) ;
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+ } ) ;
14321454 } ) ;
14331455 } ) ;
14341456
You can’t perform that action at this time.
0 commit comments