We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ddc7125 commit e185904Copy full SHA for e185904
1 file changed
packages/tests-e2e/src/connect/utils/AuthenticatorApp.ts
@@ -30,11 +30,16 @@ export class AuthenticatorApp {
30
const wrapped = this.#existing.get(secret);
31
if (!wrapped) return null;
32
33
- const now = Date.now();
34
- if (now < wrapped.nextBoundary) {
35
- await new Promise(resolve => setTimeout(resolve, wrapped.nextBoundary - now));
+ const safetyMargin = 2_000;
+ let now = Date.now();
+
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);
39
}
40
41
+ await new Promise(resolve => setTimeout(resolve, wrapped.nextBoundary - now + safetyMargin));
42
43
const then = Date.now();
44
const result = generateToken(secret);
45
if (!result) return null;
0 commit comments