Skip to content

Commit c917387

Browse files
clear storage backoff timeout on success
clearing timeouts frees resources (and allows for node processes to exit)
1 parent 4512bc9 commit c917387

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/storage/src/implementation/backoff.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function start(
4242
// TODO: find a way to exclude Node type definition for storage because storage only works in browser
4343
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4444
let timeoutId: any = null;
45+
let hitTimeoutId: any = null;
4546
let hitTimeout = false;
4647
let cancelState = 0;
4748

@@ -69,6 +70,9 @@ export function start(
6970
return;
7071
}
7172
if (success) {
73+
if (hitTimeoutId !== null) {
74+
clearTimeout(hitTimeoutId);
75+
}
7276
triggerCallback.call(null, success, ...args);
7377
return;
7478
}
@@ -113,7 +117,8 @@ export function start(
113117
}
114118
}
115119
callWithDelay(0);
116-
setTimeout(() => {
120+
hitTimeoutId = setTimeout(function () {
121+
hitTimeoutId = null;
117122
hitTimeout = true;
118123
stop(true);
119124
}, timeout);

0 commit comments

Comments
 (0)