Skip to content

Commit 2269d0b

Browse files
committed
Added more crosslinks
1 parent 268962a commit 2269d0b

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

docs/context.mdx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ title: "Context"
33
description: "Get the context of a task run."
44
---
55

6-
Context (`ctx`) is a way to get information about a task. Here's an example:
6+
Context (`ctx`) is a way to get information about a run.
7+
8+
<Note>
9+
The context object does not change whilst your code is executing. This means values like `ctx.run.durationMs` will be fixed at the moment the `run()` function is called.
10+
</Note>
11+
12+
Here's an example:
713

814
```typescript
915
import { task } from "@trigger.dev/sdk/v3";
@@ -22,10 +28,9 @@ export const parentTask = task({
2228
## Context properties
2329

2430
<ResponseField name="task" type="object">
25-
Information about the task being executed.
26-
<Expandable title="properties">
31+
<Expandable title="properties" defaultOpen={true}>
2732
<ResponseField name="exportName" type="string">
28-
The export name of the task.
33+
The exported function name of the task e.g. `myTask` if you defined it like this: `export const myTask = task(...)`.
2934
</ResponseField>
3035
<ResponseField name="id" type="string">
3136
The ID of the task.
@@ -37,7 +42,6 @@ export const parentTask = task({
3742
</ResponseField>
3843

3944
<ResponseField name="attempt" type="object">
40-
Information about the current execution attempt.
4145
<Expandable title="properties">
4246
<ResponseField name="id" type="string">
4347
The ID of the execution attempt.
@@ -61,7 +65,6 @@ export const parentTask = task({
6165
</ResponseField>
6266

6367
<ResponseField name="run" type="object">
64-
Information about the task run.
6568
<Expandable title="properties">
6669
<ResponseField name="id" type="string">
6770
The ID of the task run.
@@ -70,10 +73,10 @@ export const parentTask = task({
7073
The context of the task run.
7174
</ResponseField>
7275
<ResponseField name="tags" type="array">
73-
An array of tags associated with the task run.
76+
An array of [tags](/tags) associated with the task run.
7477
</ResponseField>
7578
<ResponseField name="isTest" type="boolean">
76-
Whether this is a test run.
79+
Whether this is a [test run](/run-tests).
7780
</ResponseField>
7881
<ResponseField name="createdAt" type="date">
7982
The creation time of the task run.
@@ -82,31 +85,30 @@ export const parentTask = task({
8285
The start time of the task run.
8386
</ResponseField>
8487
<ResponseField name="idempotencyKey" type="string" optional>
85-
An optional idempotency key for the task run.
88+
An optional [idempotency key](/idempotency) for the task run.
8689
</ResponseField>
8790
<ResponseField name="maxAttempts" type="number" optional>
88-
The maximum number of attempts allowed for this task run.
91+
The [maximum number of attempts](/triggering#maxattempts) allowed for this task run.
8992
</ResponseField>
9093
<ResponseField name="durationMs" type="number">
91-
The duration of the task run in milliseconds.
94+
The duration of the task run in milliseconds when the `run()` function is called. For live values use the [usage SDK functions](/run-usage).
9295
</ResponseField>
9396
<ResponseField name="costInCents" type="number">
94-
The cost of the task run in cents.
97+
The cost of the task run in cents when the `run()` function is called. For live values use the [usage SDK functions](/run-usage).
9598
</ResponseField>
9699
<ResponseField name="baseCostInCents" type="number">
97-
The base cost of the task run in cents.
100+
The base cost of the task run in cents when the `run()` function is called. For live values use the [usage SDK functions](/run-usage).
98101
</ResponseField>
99102
<ResponseField name="version" type="string" optional>
100-
The version of the task run.
103+
The [version](/versioning) of the task run.
101104
</ResponseField>
102105
<ResponseField name="maxDuration" type="number" optional>
103-
The maximum allowed duration for the task run.
106+
The [maximum allowed duration](/runs/max-duration) for the task run.
104107
</ResponseField>
105108
</Expandable>
106109
</ResponseField>
107110

108111
<ResponseField name="queue" type="object">
109-
Information about the queue the task is running in.
110112
<Expandable title="properties">
111113
<ResponseField name="id" type="string">
112114
The ID of the queue.
@@ -118,7 +120,6 @@ export const parentTask = task({
118120
</ResponseField>
119121

120122
<ResponseField name="environment" type="object">
121-
Information about the execution environment.
122123
<Expandable title="properties">
123124
<ResponseField name="id" type="string">
124125
The ID of the environment.
@@ -133,7 +134,6 @@ export const parentTask = task({
133134
</ResponseField>
134135

135136
<ResponseField name="organization" type="object">
136-
Information about the organization.
137137
<Expandable title="properties">
138138
<ResponseField name="id" type="string">
139139
The ID of the organization.
@@ -148,7 +148,6 @@ export const parentTask = task({
148148
</ResponseField>
149149

150150
<ResponseField name="project" type="object">
151-
Information about the project.
152151
<Expandable title="properties">
153152
<ResponseField name="id" type="string">
154153
The ID of the project.

0 commit comments

Comments
 (0)