Skip to content

Commit

Permalink
Added soft-lock protection
Browse files Browse the repository at this point in the history
  • Loading branch information
TwoAbove committed Jan 26, 2024
1 parent d877d63 commit 06c032a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/services/seedSearcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -237,7 +246,6 @@ export class SeedSearcher {

async stop() {
this.shouldCancel = true;
this.running = false;
}

onInfo(cb: (info: ReturnType<SeedSearcher["getInfo"]>) => void) {
Expand Down Expand Up @@ -265,7 +273,7 @@ export class SeedSearcher {
currentSeed: this.currentSeed,
foundSeed: this.foundSeed,
running: this.running,
}
},
);
}

Expand Down

0 comments on commit 06c032a

Please sign in to comment.