From 06c032a0c0f3b94f60a4cbae29350208b650969e Mon Sep 17 00:00:00 2001 From: Seva Maltsev Date: Fri, 26 Jan 2024 13:19:32 -0500 Subject: [PATCH] Added soft-lock protection --- src/services/seedSearcher.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/services/seedSearcher.ts b/src/services/seedSearcher.ts index 3ca8bee..122c696 100755 --- a/src/services/seedSearcher.ts +++ b/src/services/seedSearcher.ts @@ -146,6 +146,15 @@ export class SeedSearcher { async work() { this.running = true; this.shouldCancel = false; + + // we need a failsafe for too-long loops, so we'll just stop after 5 minutes + setTimeout( + () => { + this.shouldCancel = true; + }, + 1000 * 60 * 5, + ); + // console.profile(); while (!this.shouldCancel && this.currentSeed <= (this.seedEnd || 2_147_483_645)) { if (this.count && this.count % this.gcEvery === 0) { @@ -237,7 +246,6 @@ export class SeedSearcher { async stop() { this.shouldCancel = true; - this.running = false; } onInfo(cb: (info: ReturnType) => void) { @@ -265,7 +273,7 @@ export class SeedSearcher { currentSeed: this.currentSeed, foundSeed: this.foundSeed, running: this.running, - } + }, ); }