mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 03:01:04 -05:00
fix: Update activeTasks key handling to ensure string consistency
This commit is contained in:
@@ -73,7 +73,7 @@ export class MarkovStore {
|
|||||||
/**
|
/**
|
||||||
* Save chains to serialized storage with debouncing
|
* Save chains to serialized storage with debouncing
|
||||||
*/
|
*/
|
||||||
private async save(): Promise<void> {
|
public async save(): Promise<void> {
|
||||||
if (!this.dirty) return;
|
if (!this.dirty) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export class WorkerPool extends EventEmitter {
|
|||||||
const task = sortedTasks.shift()!;
|
const task = sortedTasks.shift()!;
|
||||||
|
|
||||||
this.taskQueue = sortedTasks;
|
this.taskQueue = sortedTasks;
|
||||||
this.activeTasks.set(availableWorkerId, task);
|
this.activeTasks.set(String(availableWorkerId), task);
|
||||||
|
|
||||||
// Send task to worker
|
// Send task to worker
|
||||||
const worker = this.workers[availableWorkerId];
|
const worker = this.workers[availableWorkerId];
|
||||||
@@ -184,7 +184,7 @@ export class WorkerPool extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
private findAvailableWorker(): number {
|
private findAvailableWorker(): number {
|
||||||
for (let i = 0; i < this.maxWorkers; i++) {
|
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;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,7 +297,7 @@ export class WorkerPool extends EventEmitter {
|
|||||||
activeWorkers: this.activeTasks.size,
|
activeWorkers: this.activeTasks.size,
|
||||||
queuedTasks: this.taskQueue.length,
|
queuedTasks: this.taskQueue.length,
|
||||||
activeTasks: Array.from(this.activeTasks.keys()),
|
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++) {
|
for (let i = 0; i < this.maxWorkers; i++) {
|
||||||
const worker = this.workers[i];
|
const worker = this.workers[i];
|
||||||
if (worker) {
|
if (worker) {
|
||||||
shutdownPromises.push(worker.terminate());
|
shutdownPromises.push(worker.terminate().then(() => {}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user