Skip to content

Commit

Permalink
Add buffer to notification timeout to ensure locks are avoided.
Browse files Browse the repository at this point in the history
  • Loading branch information
claabs committed Feb 6, 2024
1 parent 89c8ea4 commit f301374
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/device-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface DeviceLoginProps {
const hashAlphabet = 'abcdefghijklmnopqrstuvwxyz';
const hashLength = 4;
const hashids = new Hashids(Math.random().toString(), hashLength, hashAlphabet);
const timeoutBufferMs = 30 * 1000;

export const promiseTimeout = <T>(
timeoutMs: number,
Expand Down Expand Up @@ -127,7 +128,7 @@ export class DeviceLogin {

public async testServerNotify(): Promise<void> {
const { reqId, url } = getUniqueUrl();
const notificationTimeout = config.getMsUntilNextRun();
const notificationTimeout = config.getMsUntilNextRun() - timeoutBufferMs;

logger.trace(
{ notificationTimeout: `in ${(notificationTimeout / (60 * 1000)).toFixed(1)} minutes` },
Expand All @@ -149,7 +150,7 @@ export class DeviceLogin {

public async newDeviceAuthLogin(): Promise<void> {
const { reqId, url } = getUniqueUrl();
const notificationTimeout = config.getMsUntilNextRun();
const notificationTimeout = config.getMsUntilNextRun() - timeoutBufferMs;

logger.trace(
{ notificationTimeout: `in ${(notificationTimeout / (60 * 1000)).toFixed(1)} minutes` },
Expand Down

0 comments on commit f301374

Please sign in to comment.