Skip to content

Fix queued snapshot status handler #1963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/wet-deers-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"trigger.dev": patch
"@trigger.dev/core": patch
---

Fix QUEUED status snapshot handler
10 changes: 8 additions & 2 deletions packages/cli-v3/src/entryPoints/managed/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ export class RunExecution {
this.abortExecution();
return;
}
case "QUEUED": {
this.sendDebugLog("Run was re-queued", snapshotMetadata);

// Pretend we've just suspended the run. This will kill the process without failing the run.
await this.taskRunProcess?.suspend();
return;
}
case "FINISHED": {
this.sendDebugLog("Run is finished", snapshotMetadata);

Expand Down Expand Up @@ -402,8 +409,7 @@ export class RunExecution {

return;
}
case "RUN_CREATED":
case "QUEUED": {
case "RUN_CREATED": {
this.sendDebugLog("Invalid status change", snapshotMetadata);

this.abortExecution();
Expand Down
21 changes: 13 additions & 8 deletions packages/core/src/v3/runtime/managedRuntimeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ export class ManagedRuntimeManager implements RuntimeManager {
private ipc: ExecutorToWorkerProcessConnection,
private showLogs: boolean
) {
setTimeout(() => {
this.log("Runtime status", {
resolversbyWaitId: this.resolversByWaitId.keys(),
resolversByWaitpoint: this.resolversByWaitpoint.keys(),
});
}, 1000);
// Log out the runtime status on a long interval to help debug stuck executions
setInterval(() => {
this.log("[DEBUG] ManagedRuntimeManager status", this.status);
}, 300_000);
}

disable(): void {
Expand Down Expand Up @@ -178,14 +176,14 @@ export class ManagedRuntimeManager implements RuntimeManager {
}

if (!waitId) {
this.log("No waitId found for waitpoint", waitpoint);
this.log("No waitId found for waitpoint", { ...this.status, ...waitpoint });
return;
}

const resolve = this.resolversByWaitId.get(waitId);

if (!resolve) {
this.log("No resolver found for waitId", waitId);
this.log("No resolver found for waitId", { ...this.status, waitId });
return;
}

Expand Down Expand Up @@ -227,4 +225,11 @@ export class ManagedRuntimeManager implements RuntimeManager {
if (!this.showLogs) return;
console.log(`[${new Date().toISOString()}] ${message}`, args);
}

private get status() {
return {
resolversbyWaitId: Array.from(this.resolversByWaitId.keys()),
resolversByWaitpoint: Array.from(this.resolversByWaitpoint.keys()),
};
}
}
Loading
Loading