fix: Update activeTasks key handling to ensure string consistency

This commit is contained in:
pacnpal
2025-09-25 13:41:31 -04:00
parent 1f0a2573c4
commit 495b2350e0
2 changed files with 5 additions and 5 deletions

View File

@@ -73,7 +73,7 @@ export class MarkovStore {
/**
* Save chains to serialized storage with debouncing
*/
private async save(): Promise<void> {
public async save(): Promise<void> {
if (!this.dirty) return;
try {

View File

@@ -166,7 +166,7 @@ export class WorkerPool extends EventEmitter {
const task = sortedTasks.shift()!;
this.taskQueue = sortedTasks;
this.activeTasks.set(availableWorkerId, task);
this.activeTasks.set(String(availableWorkerId), task);
// Send task to worker
const worker = this.workers[availableWorkerId];
@@ -184,7 +184,7 @@ export class WorkerPool extends EventEmitter {
*/
private findAvailableWorker(): number {
for (let i = 0; i < this.maxWorkers; i++) {
if (this.workers[i] && !this.activeTasks.has(i)) {
if (this.workers[i] && !this.activeTasks.has(String(i))) {
return i;
}
}
@@ -297,7 +297,7 @@ export class WorkerPool extends EventEmitter {
activeWorkers: this.activeTasks.size,
queuedTasks: this.taskQueue.length,
activeTasks: Array.from(this.activeTasks.keys()),
availableWorkers: this.workers.filter((w, i) => w && !this.activeTasks.has(i)).length
availableWorkers: this.workers.filter((w, i) => w && !this.activeTasks.has(String(i))).length
};
}
@@ -341,7 +341,7 @@ export class WorkerPool extends EventEmitter {
for (let i = 0; i < this.maxWorkers; i++) {
const worker = this.workers[i];
if (worker) {
shutdownPromises.push(worker.terminate());
shutdownPromises.push(worker.terminate().then(() => {}));
}
}