Skip to content

Commit bb27273

Browse files
committed
fix: fetcherPool running forever when no accounts were add to the queue
1 parent c62e44e commit bb27273

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/core/src/utils/concurrence/pendingWork.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ export class PendingWorkPool<T> {
161161
const minSleepTimeRef = await concurrentPromises(generator, concurrency)
162162

163163
const sleep = this.skipSleep
164-
? 1
164+
? 0
165165
: minSleepTimeRef.value === MAX_TIMER_INTEGER
166-
? this.options.interval
166+
? this.debouncedJob
167+
? undefined
168+
: this.options.interval
167169
: minSleepTimeRef.value
168170

169171
this.skipSleep = false

packages/framework/src/services/fetcher/src/fetcherPool.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export class FetcherPool<T> extends PendingWorkPool<T> {
7979
})
8080
}
8181

82+
// @note: sleepTime for a fetcher is always between [0, N] never undefined (stop)
83+
// in case it should stop the checkComplete will remove it from the pool
8284
protected async getSleepTime(
8385
fetcher: BaseHistoryFetcher<any>,
8486
): Promise<number> {

0 commit comments

Comments
 (0)