Skip to content

Commit 14dcc76

Browse files
authored
feat: run.ctx tidying and additions (#2322)
* Cleanup context and execution creation, cache stuff, add parent and root task run ids * more efficient by using friendly IDs instead of doing joins * metadata.root/parent now reference current run when run has no root/parent * Adding changeset * try to make test less flaky * Clean imports * Another attempt to fix the flaky test * Fix usage by still passing durationMs and costInCents to the execution, just not the run.ctx
1 parent 5ea6605 commit 14dcc76

38 files changed

+1445
-400
lines changed

.changeset/giant-plums-smash.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
"@trigger.dev/sdk": patch
3+
---
4+
5+
Added and cleaned up the run ctx param:
6+
7+
- New optional properties `ctx.run.parentTaskRunId` and `ctx.run.rootTaskRunId` reference the current run's root/parent ID.
8+
- Removed deprecated properties from `ctx`
9+
- Added a new `ctx.deployment` object that contains information about the deployment associated with the run.
10+
11+
We also update `metadata.root` and `metadata.parent` to work even when the run is a "root" run (meaning it doesn't have a parent or a root associated run). This now works:
12+
13+
```ts
14+
metadata.root.set("foo", "bar");
15+
metadata.parent.set("baz", 1);
16+
metadata.current().foo // "bar"
17+
metadata.current().baz // 1
18+
```

0 commit comments

Comments
 (0)