Skip to content

Commit

Permalink
fix(worker-management): Prevent termination of running workers (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi committed Apr 22, 2024
1 parent 134a4a1 commit cd4a7c0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/webWorkerManager/webWorkerManager.js
Expand Up @@ -155,8 +155,11 @@ class CentralizedWorkerManager {
}
const workerProperties = this.workerRegistry[workerName];

workerProperties.processing = true;

const results = await api[methodName](args, ...finalCallbacks);

workerProperties.processing = false;
workerProperties.lastActiveTime[index] = Date.now();

// If auto termination is enabled and the interval is not set, set it.
Expand Down Expand Up @@ -201,6 +204,11 @@ class CentralizedWorkerManager {

terminateIdleWorkers(workerName, idleTimeThreshold) {
const workerProperties = this.workerRegistry[workerName];

if (workerProperties.processing) {
return;
}

const now = Date.now();

workerProperties.instances.forEach((_, index) => {
Expand Down

0 comments on commit cd4a7c0

Please sign in to comment.