allow debounceAsync-ed to always access a valid value instead of undefined

Massimo Melina committed Apr 13, 2022 at 18:48 UTC 50372414683a140f67d688c5ea2593bbdda4e7df
1 file changed +2 -1
server/src/misc.ts
+2 -1
@@ -188,7 +188,8 @@ export function debounceAsync<CB extends (...args: any[]) => Promise<R>, R>(
188 await new Promise(resolve => setTimeout(resolve, waitFor))
189 if (!whoIsWaiting) // canceled
190 return void(waitingSince = 0)
191 - if (whoIsWaiting !== args) return // another fresher call is waiting
191 + if (whoIsWaiting !== args) // another fresher call is waiting
192 + return runningDebouncer
193 waitingSince = 0
194 whoIsWaiting = undefined
195 started = Date.now()