Skip to content

Commit 57c1f5f

Browse files
committed
Merge remote-tracking branch 'origin/main' into checkpoint-cleanup
2 parents c900253 + 69ec68e commit 57c1f5f

File tree

14 files changed

+85
-19
lines changed

14 files changed

+85
-19
lines changed

.changeset/three-olives-love.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/tasks/overview.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ export const taskWithInitReturn = task({
155155
});
156156
```
157157

158+
<Info>
159+
Errors thrown in the `init` function are ignored.
160+
</Info>
161+
158162
### `cleanup` function
159163

160164
This function is called after the `run` function is executed, regardless of whether the run was successful or not. It's useful for cleaning up resources, logging, or other side effects.
@@ -171,10 +175,18 @@ export const taskWithCleanup = task({
171175
});
172176
```
173177

178+
<Info>
179+
Errors thrown in the `cleanup` function will fail the attempt.
180+
</Info>
181+
174182
### `middleware` function
175183

176184
This function is called before the `run` function, it allows you to wrap the run function with custom code.
177185

186+
<Info>
187+
An error thrown in `middleware` is just like an uncaught error in the run function: it will propagate through to `handleError()` and then will fail the attempt (causing a retry).
188+
</Info>
189+
178190
### `onStart` function
179191

180192
When a task run starts, the `onStart` function is called. It's useful for sending notifications, logging, and other side effects. This function will only be called one per run (not per retry). If you want to run code before each retry, use the `init` function.
@@ -204,6 +216,10 @@ export default defineConfig({
204216
});
205217
```
206218

219+
<Info>
220+
Errors thrown in the `onStart` function are ignored.
221+
</Info>
222+
207223
### `onSuccess` function
208224

209225
When a task run succeeds, the `onSuccess` function is called. It's useful for sending notifications, logging, syncing state to your database, or other side effects.
@@ -233,6 +249,10 @@ export default defineConfig({
233249
});
234250
```
235251

252+
<Info>
253+
Errors thrown in the `onSuccess` function are ignored.
254+
</Info>
255+
236256
### `onFailure` function
237257

238258
When a task run fails, the `onFailure` function is called. It's useful for sending notifications, logging, or other side effects. It will only be executed once the task run has exhausted all its retries.
@@ -262,12 +282,20 @@ export default defineConfig({
262282
});
263283
```
264284

285+
<Info>
286+
Errors thrown in the `onFailure` function are ignored.
287+
</Info>
288+
265289
### `handleError` functions
266290

267291
You can define a function that will be called when an error is thrown in the `run` function, that allows you to control how the error is handled and whether the task should be retried.
268292

269293
Read more about `handleError` in our [Errors and Retrying guide](/errors-retrying).
270294

295+
<Info>
296+
Uncaught errors will throw a special internal error of the type `HANDLE_ERROR_ERROR`.
297+
</Info>
298+
271299
## Next steps
272300

273301
<CardGroup>

packages/build/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @trigger.dev/build
22

3+
## 3.0.9
4+
5+
### Patch Changes
6+
7+
- Updated dependencies:
8+
- `@trigger.dev/core@3.0.9`
9+
310
## 3.0.8
411

512
### Patch Changes

packages/build/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trigger.dev/build",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"description": "trigger.dev build extensions",
55
"license": "MIT",
66
"publishConfig": {
@@ -65,7 +65,7 @@
6565
"check-exports": "attw --pack ."
6666
},
6767
"dependencies": {
68-
"@trigger.dev/core": "workspace:3.0.8",
68+
"@trigger.dev/core": "workspace:3.0.9",
6969
"pkg-types": "^1.1.3",
7070
"tinyglobby": "^0.2.2",
7171
"tsconfck": "3.1.3"

packages/cli-v3/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# trigger.dev
22

3+
## 3.0.9
4+
5+
### Patch Changes
6+
7+
- Updated dependencies:
8+
- `@trigger.dev/core@3.0.9`
9+
- `@trigger.dev/build@3.0.9`
10+
311
## 3.0.8
412

513
### Patch Changes

packages/cli-v3/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "trigger.dev",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"description": "A Command-Line Interface for Trigger.dev (v3) projects",
55
"type": "module",
66
"license": "MIT",
@@ -87,8 +87,8 @@
8787
"@opentelemetry/sdk-trace-base": "1.25.1",
8888
"@opentelemetry/sdk-trace-node": "1.25.1",
8989
"@opentelemetry/semantic-conventions": "1.25.1",
90-
"@trigger.dev/build": "workspace:3.0.8",
91-
"@trigger.dev/core": "workspace:3.0.8",
90+
"@trigger.dev/build": "workspace:3.0.9",
91+
"@trigger.dev/core": "workspace:3.0.9",
9292
"c12": "^1.11.1",
9393
"chalk": "^5.2.0",
9494
"cli-table3": "^0.6.3",

packages/core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# internal-platform
22

3+
## 3.0.9
4+
5+
### Patch Changes
6+
7+
- fix: run metadata not working when using npx/pnpm dlx ([`4c1ee3d6e`](https://github.com/triggerdotdev/trigger.dev/commit/4c1ee3d6ea5f2e1dfc9f475c99ecd236bf780a19))
8+
39
## 3.0.8
410

511
### Patch Changes

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trigger.dev/core",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"description": "Core code used across the Trigger.dev SDK and platform",
55
"license": "MIT",
66
"publishConfig": {

packages/core/src/v3/runMetadata/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { DeserializedJson } from "../../schemas/json.js";
22
import { apiClientManager } from "../apiClientManager-api.js";
33
import { taskContext } from "../task-context-api.js";
4+
import { getGlobal, registerGlobal } from "../utils/globals.js";
45
import { ApiRequestOptions } from "../zodfetch.js";
56

7+
const API_NAME = "run-metadata";
8+
69
export class RunMetadataAPI {
710
private static _instance?: RunMetadataAPI;
8-
private store: Record<string, DeserializedJson> | undefined;
911

1012
private constructor() {}
1113

@@ -17,8 +19,16 @@ export class RunMetadataAPI {
1719
return this._instance;
1820
}
1921

22+
get store(): Record<string, DeserializedJson> | undefined {
23+
return getGlobal(API_NAME);
24+
}
25+
26+
set store(value: Record<string, DeserializedJson> | undefined) {
27+
registerGlobal(API_NAME, value, true);
28+
}
29+
2030
public enterWithMetadata(metadata: Record<string, DeserializedJson>): void {
21-
this.store = metadata;
31+
registerGlobal(API_NAME, metadata);
2232
}
2333

2434
public current(): Record<string, DeserializedJson> | undefined {

packages/core/src/v3/utils/globals.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DeserializedJson } from "../../schemas/json.js";
12
import { ApiClientConfiguration } from "../apiClientManager/types.js";
23
import { Clock } from "../clock/clock.js";
34
import type { RuntimeManager } from "../runtime/manager.js";
@@ -54,4 +55,5 @@ type TriggerDotDevGlobalAPI = {
5455
["task-catalog"]?: TaskCatalog;
5556
["task-context"]?: TaskContext;
5657
["api-client"]?: ApiClientConfiguration;
58+
["run-metadata"]?: Record<string, DeserializedJson>;
5759
};

packages/trigger-sdk/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @trigger.dev/sdk
22

3+
## 3.0.9
4+
5+
### Patch Changes
6+
7+
- Removed the inline-code accessory from the logs when calling trigger or batchTrigger from a run ([#1364](https://github.com/triggerdotdev/trigger.dev/pull/1364))
8+
- Updated dependencies:
9+
- `@trigger.dev/core@3.0.9`
10+
311
## 3.0.8
412

513
### Patch Changes

packages/trigger-sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trigger.dev/sdk",
3-
"version": "3.0.8",
3+
"version": "3.0.9",
44
"description": "trigger.dev Node.JS SDK",
55
"license": "MIT",
66
"publishConfig": {
@@ -48,7 +48,7 @@
4848
"@opentelemetry/api": "1.9.0",
4949
"@opentelemetry/api-logs": "0.52.1",
5050
"@opentelemetry/semantic-conventions": "1.25.1",
51-
"@trigger.dev/core": "workspace:3.0.8",
51+
"@trigger.dev/core": "workspace:3.0.9",
5252
"chalk": "^5.2.0",
5353
"cronstrue": "^2.21.0",
5454
"debug": "^4.3.4",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

references/v3-catalog/src/trigger/runMetadata.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export const runMetadataTask = task({
1919
export const runMetadataChildTask = task({
2020
id: "run-metadata-child-task",
2121
run: async (payload: any, { ctx }) => {
22+
logger.info("metadata", { metadata: metadata.current() });
23+
2224
await metadata.set("child", "task");
2325

2426
logger.info("metadata", { metadata: metadata.current() });

0 commit comments

Comments
 (0)