Skip to content

Commit 084cb47

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/placement-tags
2 parents 9b3a7df + 1a88809 commit 084cb47

File tree

18 files changed

+311
-137
lines changed

18 files changed

+311
-137
lines changed

.changeset/famous-clocks-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
---
4+
5+
feat: Support AI SDK 5.0. `ai.tool` now accepts either a schemaTask or a task with a provided jsonSchema
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
fix: waitUntil now correctly waits for metadata.streams to finish

.changeset/loud-rules-dream.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
fix(runner): prevent retry immediately race condition which can cause stuck runs that end up being system failures

.changeset/mean-wolves-stare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trigger.dev": patch
3+
---
4+
5+
Upgrade to bun v1.2.20

apps/webapp/app/v3/environmentVariables/environmentVariablesRepository.server.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,10 +850,6 @@ export async function resolveVariablesForEnvironment(
850850
...builtInVariables,
851851
]);
852852

853-
logger.debug("Resolved variables", {
854-
result,
855-
});
856-
857853
return result;
858854
}
859855

packages/cli-v3/src/deploy/buildImage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ export type GenerateContainerfileOptions = {
543543
};
544544

545545
const BASE_IMAGE: Record<BuildRuntime, string> = {
546-
bun: "imbios/bun-node:1.2.18-20-slim@sha256:74067c73e7fe4a4da56f447f644e7090cec4eaf5500a0e384d15855107bea636",
546+
bun: "imbios/bun-node:1.2.20-20-slim@sha256:a20d1f90ee079b80dffc0041cf8a73aa05cdb135e3b3aff1ba3eba91608dba22",
547547
node: "node:21.7.3-bookworm-slim@sha256:dfc05dee209a1d7adf2ef189bd97396daad4e97c6eaa85778d6f75205ba1b0fb",
548548
"node-22":
549549
"node:22.16.0-bookworm-slim@sha256:048ed02c5fd52e86fda6fbd2f6a76cf0d4492fd6c6fee9e2c463ed5108da0e34",

packages/cli-v3/src/entryPoints/dev-run-worker.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ const runMetadataManager = new StandardMetadataManager(
141141
runMetadata.setGlobalManager(runMetadataManager);
142142
const waitUntilManager = new StandardWaitUntilManager();
143143
waitUntil.setGlobalManager(waitUntilManager);
144-
// Wait for all streams to finish before completing the run
145-
waitUntil.register({
146-
requiresResolving: () => runMetadataManager.hasActiveStreams(),
147-
promise: () => runMetadataManager.waitForAllStreams(),
148-
});
149144

150145
const triggerLogLevel = getEnvVar("TRIGGER_LOG_LEVEL");
151146
const showInternalLogs = getEnvVar("RUN_WORKER_SHOW_LOGS") === "true";
@@ -309,6 +304,12 @@ function resetExecutionEnvironment() {
309304
taskContext.disable();
310305
standardTraceContextManager.reset();
311306

307+
// Wait for all streams to finish before completing the run
308+
waitUntil.register({
309+
requiresResolving: () => runMetadataManager.hasActiveStreams(),
310+
promise: () => runMetadataManager.waitForAllStreams(),
311+
});
312+
312313
log(`[${new Date().toISOString()}] Reset execution environment`);
313314
}
314315

packages/cli-v3/src/entryPoints/managed-run-worker.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ runMetadata.setGlobalManager(runMetadataManager);
133133

134134
const waitUntilManager = new StandardWaitUntilManager();
135135
waitUntil.setGlobalManager(waitUntilManager);
136-
// Wait for all streams to finish before completing the run
137-
waitUntil.register({
138-
requiresResolving: () => runMetadataManager.hasActiveStreams(),
139-
promise: () => runMetadataManager.waitForAllStreams(),
140-
});
141136

142137
const triggerLogLevel = getEnvVar("TRIGGER_LOG_LEVEL");
143138

@@ -295,6 +290,12 @@ function resetExecutionEnvironment() {
295290
taskContext.disable();
296291
standardTraceContextManager.reset();
297292

293+
// Wait for all streams to finish before completing the run
294+
waitUntil.register({
295+
requiresResolving: () => runMetadataManager.hasActiveStreams(),
296+
promise: () => runMetadataManager.waitForAllStreams(),
297+
});
298+
298299
console.log(`[${new Date().toISOString()}] Reset execution environment`);
299300
}
300301

packages/cli-v3/src/entryPoints/managed/execution.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class RunExecution {
7777
private shutdownReason?: string;
7878

7979
private isCompletingRun = false;
80+
private ignoreSnapshotChanges = false;
8081

8182
private supervisorSocket: SupervisorSocket;
8283
private notifier?: RunNotifier;
@@ -237,6 +238,16 @@ export class RunExecution {
237238
completedWaitpoints: completedWaitpoints.length,
238239
};
239240

241+
if (this.ignoreSnapshotChanges) {
242+
this.sendDebugLog("processSnapshotChange: ignoring snapshot change", {
243+
incomingSnapshotId: snapshot.friendlyId,
244+
completedWaitpoints: completedWaitpoints.length,
245+
currentAttemptNumber: this.currentAttemptNumber,
246+
newAttemptNumber: run.attemptNumber,
247+
});
248+
return;
249+
}
250+
240251
if (!this.snapshotManager) {
241252
this.sendDebugLog("handleSnapshotChange: missing snapshot manager", snapshotMetadata);
242253
return;
@@ -808,7 +819,9 @@ export class RunExecution {
808819
}
809820

810821
// Start and execute next attempt
811-
const [startError, start] = await tryCatch(this.startAttempt({ isWarmStart: true }));
822+
const [startError, start] = await tryCatch(
823+
this.enableIgnoreSnapshotChanges(() => this.startAttempt({ isWarmStart: true }))
824+
);
812825

813826
if (startError) {
814827
this.sendDebugLog("failed to start attempt for retry", { error: startError.message });
@@ -829,6 +842,15 @@ export class RunExecution {
829842
}
830843
}
831844

845+
private async enableIgnoreSnapshotChanges<T>(fn: () => Promise<T>): Promise<T> {
846+
this.ignoreSnapshotChanges = true;
847+
try {
848+
return await fn();
849+
} finally {
850+
this.ignoreSnapshotChanges = false;
851+
}
852+
}
853+
832854
/**
833855
* Restores a suspended execution from PENDING_EXECUTING
834856
*/

packages/core/src/v3/types/tasks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ export interface Task<TIdentifier extends string, TInput = void, TOutput = any>
547547

548548
description?: string;
549549

550+
jsonSchema?: JSONSchema;
551+
550552
/**
551553
* Trigger a task with the given payload, and continue without waiting for the result. If you want to wait for the result, use `triggerAndWait`. Returns the id of the triggered task run.
552554
* @param payload

0 commit comments

Comments
 (0)