Skip to content

Commit 5c9788c

Browse files
committed
Fixed typecheck errors
1 parent ac92a20 commit 5c9788c

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

packages/cli-v3/src/dev/devSupervisor.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class DevSupervisor implements WorkerRuntime {
8080
private activeRunsPath?: string;
8181
private watchdogPidPath?: string;
8282

83-
constructor(public readonly options: WorkerRuntimeOptions) {}
83+
constructor(public readonly options: WorkerRuntimeOptions) { }
8484

8585
async init(): Promise<void> {
8686
logger.debug("[DevSupervisor] initialized worker runtime", { options: this.options });
@@ -117,8 +117,8 @@ class DevSupervisor implements WorkerRuntime {
117117
typeof processKeepAlive === "boolean"
118118
? processKeepAlive
119119
: typeof processKeepAlive === "object"
120-
? processKeepAlive.enabled
121-
: false;
120+
? processKeepAlive.enabled
121+
: false;
122122

123123
const maxPoolSize =
124124
typeof processKeepAlive === "object" ? processKeepAlive.devMaxPoolSize ?? 25 : 25;
@@ -279,10 +279,10 @@ class DevSupervisor implements WorkerRuntime {
279279
// Clean up files
280280
try {
281281
if (this.activeRunsPath) unlinkSync(this.activeRunsPath);
282-
} catch {}
282+
} catch { }
283283
try {
284284
if (this.watchdogPidPath) unlinkSync(this.watchdogPidPath);
285-
} catch {}
285+
} catch { }
286286
}
287287

288288
#updateActiveRunsFile() {
@@ -517,7 +517,7 @@ class DevSupervisor implements WorkerRuntime {
517517

518518
//stop the worker if it is deprecated and there are no more runs
519519
if (worker.deprecated) {
520-
this.#tryDeleteWorker(message.backgroundWorker.friendlyId).finally(() => {});
520+
this.#tryDeleteWorker(message.backgroundWorker.friendlyId).finally(() => { });
521521
}
522522
},
523523
onSubscribeToRunNotifications: async (run, snapshot) => {
@@ -614,7 +614,7 @@ class DevSupervisor implements WorkerRuntime {
614614
}
615615

616616
existingWorker.deprecate();
617-
this.#tryDeleteWorker(workerId).finally(() => {});
617+
this.#tryDeleteWorker(workerId).finally(() => { });
618618
}
619619

620620
this.workers.set(worker.serverWorker.id, worker);
@@ -745,15 +745,24 @@ class DevSupervisor implements WorkerRuntime {
745745
this.#cleanupWorker(friendlyId);
746746
}
747747

748+
#hasActiveRunsForWorker(friendlyId: string): boolean {
749+
for (const controller of this.runControllers.values()) {
750+
try {
751+
if (controller.workerFriendlyId === friendlyId) return true;
752+
} catch {
753+
// workerFriendlyId may throw if the controller is in an unexpected state
754+
}
755+
}
756+
return false;
757+
}
758+
748759
#cleanupWorker(friendlyId: string) {
749760
const worker = this.workers.get(friendlyId);
750761
if (!worker) {
751762
return;
752763
}
753764

754-
// Check if any active runs still reference this worker
755-
756-
if (hasActiveRuns) {
765+
if (this.#hasActiveRunsForWorker(friendlyId)) {
757766
logger.debug("[DevSupervisor] Worker still has active runs, skipping cleanup", {
758767
workerId: friendlyId,
759768
});
@@ -775,16 +784,7 @@ class DevSupervisor implements WorkerRuntime {
775784
for (const [id, worker] of this.workers.entries()) {
776785
if (!worker.deprecated) continue;
777786

778-
// Skip workers with active runs
779-
const hasActiveRuns = Array.from(this.runControllers.values()).some((controller) => {
780-
try {
781-
return controller.workerFriendlyId === id;
782-
} catch {
783-
return false;
784-
}
785-
});
786-
787-
if (!hasActiveRuns) {
787+
if (!this.#hasActiveRunsForWorker(id)) {
788788
deprecatedWorkers.push({ id, worker });
789789
}
790790
}
@@ -815,12 +815,12 @@ class DevSupervisor implements WorkerRuntime {
815815

816816
type ValidationIssue =
817817
| {
818-
type: "duplicateTaskId";
819-
duplicationTaskIds: string[];
820-
}
818+
type: "duplicateTaskId";
819+
duplicationTaskIds: string[];
820+
}
821821
| {
822-
type: "noTasksDefined";
823-
};
822+
type: "noTasksDefined";
823+
};
824824

825825
function validateWorkerManifest(manifest: WorkerManifest): ValidationIssue | undefined {
826826
const issues: ValidationIssue[] = [];

0 commit comments

Comments
 (0)