Skip to content

Commit

Permalink
Merge pull request #333 from TwoAbove/fix-soft-lock
Browse files Browse the repository at this point in the history
Added soft-lock protection
  • Loading branch information
TwoAbove authored Jan 26, 2024
2 parents d877d63 + 06c032a commit 7c8bca1
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 7c8bca1

Please sign in to comment.