mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-30 19:38:34 +03:00
Merge pull request #1113 from CyberPhoenix90/fix_interval_leak
fix leak that was killing performance over long periods
This commit is contained in:
@@ -26,7 +26,10 @@ export default class Utils {
|
|||||||
/** Function that can be used to wait for a condition before returning. */
|
/** Function that can be used to wait for a condition before returning. */
|
||||||
async wait<T>(condition: () => T | false, timeout = 5000, check = 100): Promise<T> {
|
async wait<T>(condition: () => T | false, timeout = 5000, check = 100): Promise<T> {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
setTimeout(() => reject("TIMEOUT"), timeout);
|
setTimeout(() => {
|
||||||
|
clearInterval(interval);
|
||||||
|
reject("TIMEOUT");
|
||||||
|
}, timeout);
|
||||||
|
|
||||||
const intervalCheck = () => {
|
const intervalCheck = () => {
|
||||||
const result = condition();
|
const result = condition();
|
||||||
|
|||||||
Reference in New Issue
Block a user