Skip to content

Commit 5e5c97e

Browse files
authored
fix(cli): stop dev runs stuck in dequeued status (fix #2639) (#2699)
* stop deleting the first dev version files on the first change, prevents system failures * prevent dev runs getting stuck in dequeued status by deleting workers * add changeset
1 parent abd99aa commit 5e5c97e

File tree

3 files changed

+8
-58
lines changed

3 files changed

+8
-58
lines changed

.changeset/young-ligers-suffer.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
- dev runs will no longer get stuck in DEQUEUED status
6+
- prevent an ENOENT "System failure" in some dev runs when making the first change after running the dev CLI.

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,6 @@ export async function startDevSession({
148148
if (bundled) {
149149
eventBus.emit("rebuildStarted", "dev");
150150
}
151-
152-
const outdir = b.initialOptions.outdir;
153-
if (outdir && existsSync(outdir)) {
154-
logger.debug("Removing outdir", { outdir });
155-
156-
rmSync(outdir, { recursive: true, force: true });
157-
mkdirSync(outdir, { recursive: true });
158-
}
159151
});
160152
b.onEnd(async (result: esbuild.BuildResult) => {
161153
const errors = result.errors;

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

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,11 @@ class DevSupervisor implements WorkerRuntime {
264264
return;
265265
}
266266

267-
//get relevant versions
268-
//ignore deprecated and the latest worker
269-
const oldWorkerIds = this.#getActiveOldWorkers();
270-
271267
try {
272268
//todo later we should track available resources and machines used, and pass them in here (it supports it)
273269
const result = await this.options.client.dev.dequeue({
274270
currentWorker: this.latestWorkerId,
275-
oldWorkers: oldWorkerIds,
271+
oldWorkers: [], // This isn't even used on the server side, so we can just pass an empty array
276272
});
277273

278274
if (!result.success) {
@@ -285,10 +281,6 @@ class DevSupervisor implements WorkerRuntime {
285281

286282
//no runs, try again later
287283
if (result.data.dequeuedMessages.length === 0) {
288-
// logger.debug(`No dequeue runs for versions`, {
289-
// oldWorkerIds,
290-
// latestWorkerId: this.latestWorkerId,
291-
// });
292284
setTimeout(() => this.#dequeueRuns(), this.config.dequeueIntervalWithoutRun);
293285
return;
294286
}
@@ -599,42 +591,9 @@ class DevSupervisor implements WorkerRuntime {
599591
this.socket.emit("run:unsubscribe", { version: "1", runFriendlyIds: [friendlyId] });
600592
}
601593

602-
#getActiveOldWorkers() {
603-
return Array.from(this.workers.values())
604-
.filter((worker) => {
605-
//exclude the latest
606-
if (worker.serverWorker?.id === this.latestWorkerId) {
607-
return false;
608-
}
609-
610-
//if it's deprecated AND there are no executing runs, then filter it out
611-
if (worker.deprecated && worker.serverWorker?.id) {
612-
return this.#workerHasInProgressRuns(worker.serverWorker.id);
613-
}
614-
615-
return true;
616-
})
617-
.map((worker) => worker.serverWorker?.id)
618-
.filter((id): id is string => id !== undefined);
619-
}
620-
621-
#workerHasInProgressRuns(friendlyId: string) {
622-
for (const controller of this.runControllers.values()) {
623-
logger.debug("[DevSupervisor] Checking controller", {
624-
controllerFriendlyId: controller.workerFriendlyId,
625-
friendlyId,
626-
});
627-
if (controller.workerFriendlyId === friendlyId) {
628-
return true;
629-
}
630-
}
631-
632-
return false;
633-
}
634-
635594
/** Deletes the worker if there are no active runs, after a delay */
636595
async #tryDeleteWorker(friendlyId: string) {
637-
await awaitTimeout(1_000);
596+
await awaitTimeout(5_000);
638597
this.#deleteWorker(friendlyId);
639598
}
640599

@@ -651,13 +610,6 @@ class DevSupervisor implements WorkerRuntime {
651610
if (worker.serverWorker?.version) {
652611
this.taskRunProcessPool?.deprecateVersion(worker.serverWorker?.version);
653612
}
654-
655-
if (this.#workerHasInProgressRuns(friendlyId)) {
656-
return;
657-
}
658-
659-
worker.stop();
660-
this.workers.delete(friendlyId);
661613
}
662614
}
663615

0 commit comments

Comments
 (0)