File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
packages/tests-e2e/src/connect/utils Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -30,11 +30,16 @@ export class AuthenticatorApp {
3030 const wrapped = this . #existing. get ( secret ) ;
3131 if ( ! wrapped ) return null ;
3232
33- const now = Date . now ( ) ;
34- if ( now < wrapped . nextBoundary ) {
35- await new Promise ( resolve => setTimeout ( resolve , wrapped . nextBoundary - now ) ) ;
33+ const safetyMargin = 2_000 ;
34+ let now = Date . now ( ) ;
35+
36+ // If the stored boundary is already in the past, recalculate from now
37+ if ( now >= wrapped . nextBoundary ) {
38+ wrapped . nextBoundary = this . #calculateNextBoundary( now , 30_000 ) ;
3639 }
3740
41+ await new Promise ( resolve => setTimeout ( resolve , wrapped . nextBoundary - now + safetyMargin ) ) ;
42+
3843 const then = Date . now ( ) ;
3944 const result = generateToken ( secret ) ;
4045 if ( ! result ) return null ;
You can’t perform that action at this time.
0 commit comments