@@ -977,6 +977,7 @@ export class OrderedPullConsumerImpl implements Consumer {
977
977
iter : OrderedConsumerMessages | null ;
978
978
type : PullConsumerType ;
979
979
startSeq : number ;
980
+ maxInitialReset : number ;
980
981
981
982
constructor (
982
983
api : ConsumerAPI ,
@@ -998,6 +999,7 @@ export class OrderedPullConsumerImpl implements Consumer {
998
999
this . iter = null ;
999
1000
this . type = PullConsumerType . Unset ;
1000
1001
this . consumerOpts = opts ;
1002
+ this . maxInitialReset = 30 ;
1001
1003
1002
1004
// to support a random start sequence we need to update the cursor
1003
1005
this . startSeq = this . consumerOpts . opt_start_seq || 0 ;
@@ -1067,6 +1069,7 @@ export class OrderedPullConsumerImpl implements Consumer {
1067
1069
}
1068
1070
1069
1071
async resetConsumer ( seq = 0 ) : Promise < ConsumerInfo > {
1072
+ const isNew = this . serial === 0 ;
1070
1073
// try to delete the consumer
1071
1074
this . consumer ?. delete ( ) . catch ( ( ) => { } ) ;
1072
1075
seq = seq === 0 ? 1 : seq ;
@@ -1096,7 +1099,7 @@ export class OrderedPullConsumerImpl implements Consumer {
1096
1099
}
1097
1100
}
1098
1101
1099
- if ( seq === 0 && i >= 30 ) {
1102
+ if ( isNew && i >= this . maxInitialReset ) {
1100
1103
// consumer was never created, so we can fail this
1101
1104
throw err ;
1102
1105
} else {
@@ -1294,7 +1297,7 @@ export class OrderedPullConsumerImpl implements Consumer {
1294
1297
1295
1298
async info ( cached ?: boolean ) : Promise < ConsumerInfo > {
1296
1299
if ( this . currentConsumer == null ) {
1297
- this . currentConsumer = await this . resetConsumer ( this . serial ) ;
1300
+ this . currentConsumer = await this . resetConsumer ( this . startSeq ) ;
1298
1301
return Promise . resolve ( this . currentConsumer ) ;
1299
1302
}
1300
1303
if ( cached && this . currentConsumer ) {
0 commit comments