Skip to content

Commit 0d4e3e7

Browse files
authored
Lots of small docs improvements (#1251)
* tasks no longer inside a group in the side menu (and added “cron”) * Delay using a timezone * Added React Not Defined error to the troubleshooting page * Improved the React common problem * Link to v2 docs * New Development section and entry in Common Problems * Concurrently running the terminal * Fixed the .env weirdness * Added section on creating PATs for Github actions * Improved the Machine spec and limits page * Quick start steps now have nice images * Added a diagram for the lifecycle functions * Added note about onFailure * CRON -> cron/Cron * Updated the cli-dev steps for the concurrently package * Fixed capital letter * Updated diagram text * Removed dead page
1 parent bf1482f commit 0d4e3e7

20 files changed

+158
-44
lines changed

apps/webapp/app/routes/resources.orgs.$organizationSlug.select-plan.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const pricingDefinitions = {
119119
},
120120
schedules: {
121121
title: "Schedules",
122-
content: "You can attach recurring schedules to tasks using CRON syntax.",
122+
content: "You can attach recurring schedules to tasks using cron syntax.",
123123
},
124124
alerts: {
125125
title: "Alert destination",

docs/apikeys.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ Each environment has its own secret key. You can find the value on the API keys
1515

1616
To automatically configure the SDK with your secret key, you can set the `TRIGGER_SECRET_KEY` environment variable. The SDK will automatically use this value when calling API methods (like `trigger`).
1717

18-
```bash
19-
export TRIGGER_SECRET_KEY=tr_dev_…
18+
```bash .env
19+
TRIGGER_SECRET_KEY="tr_dev_…"
2020
```
2121

2222
You can do the same if you are self-hosting and need to change the default URL by using `TRIGGER_API_URL`.
2323

24-
```bash
25-
export TRIGGER_API_URL=https://trigger.example.com
24+
```bash .env
25+
TRIGGER_API_URL="https://trigger.example.com"
2626
```
2727

2828
The default URL is `https://api.trigger.dev`.

docs/cli-dev.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,46 @@ yarn dlx trigger.dev@beta dev --debugger
4848
```
4949

5050
</CodeGroup>
51+
52+
### Concurrently running the terminal
53+
54+
The concurrently package allows you to run multiple package.json scripts at the same time – in this case, your site and Trigger.dev.
55+
56+
<Steps>
57+
58+
<Step title="Install the concurrently package as a dev dependency">
59+
60+
<CodeGroup>
61+
62+
```bash npm
63+
npm i concurrently -D
64+
```
65+
66+
```bash pnpm
67+
pnpm i concurrently -D
68+
```
69+
70+
```bash yarn
71+
yarn i concurrently -D
72+
```
73+
74+
</CodeGroup>
75+
76+
</Step>
77+
78+
<Step title="Update your package.json">
79+
80+
Then add something like this in your package.json scripts. This assumes you're running Next.js so swap that bit out if you're not:
81+
82+
```json
83+
"scripts": {
84+
"dev": "concurrently --raw --kill-others npm:dev:*",
85+
"dev:next": "next dev",
86+
"dev:trigger": "npx trigger.dev@beta dev",
87+
//...
88+
}
89+
```
90+
91+
</Step>
92+
93+
</Steps>

docs/github-actions.mdx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,19 @@ jobs:
7777
7878
If you already have a GitHub action file, you can just add the final step "🚀 Deploy Trigger.dev" to your existing file.
7979
80-
You need to add the `TRIGGER_ACCESS_TOKEN` secret to your repository. You can create a new access token by going to your profile page and then clicking on the ["Personal Access Tokens"](https://cloud.trigger.dev/account/tokens) tab.
80+
### Creating a Personal Access Token
8181
82-
To set it in GitHub go to your repository, click on "Settings", "Secrets and variables" and then "Actions". Add a new secret with the name `TRIGGER_ACCESS_TOKEN` and use the value of your access token.
82+
<Steps>
8383
84-
<Accordion title="How to add TRIGGER_ACCESS_TOKEN in GitHub">
85-
1. Go to your repository on GitHub.
86-
2. Click on "Settings".
87-
3. Click on "Secrets and variables" -> "Actions"
88-
4. Click on "New repository secret".
89-
5. Add the name `TRIGGER_ACCESS_TOKEN` and the value of your access token.
84+
<Step title="Create a new access token">Go to your profile page and click on the ["Personal Access Tokens"](https://cloud.trigger.dev/account/tokens) tab.</Step>
85+
86+
<Step title="Go to your repository on GitHub.">Click on 'Settings' -> 'Secrets and variables' -> 'Actions' -> 'New repository secret'</Step>
87+
88+
<Step title="Add the TRIGGER_ACCESS_TOKEN">Add the name `TRIGGER_ACCESS_TOKEN` and the value of your access token. ![Add TRIGGER_ACCESS_TOKEN in GitHub](/images/github-access-token.png)</Step>
89+
90+
</Steps>
9091

91-
![Add TRIGGER_ACCESS_TOKEN in GitHub](/images/github-access-token.png)
9292

93-
</Accordion>
9493

9594
## Version pinning
9695

docs/images/lifecycle-functions.png

40.5 KB
Loading

docs/images/run-page.png

656 KB
Loading
75.8 KB
Loading

docs/images/test-page.png

291 KB
Loading

docs/limits.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ If you're creating schedules for your user you will definitely need to request m
4949
| Task outputs | Must not exceed 10MB |
5050

5151
Payloads and outputs that exceed 512KB will be offloaded to object storage and a presigned URL will be provided to download the data when calling `runs.retrieve`. You don't need to do anything to handle this in your tasks however, as we will transparently upload/download these during operation.
52+
53+
### Machines
54+
55+
The default machine is `small-1x` which has 0.5 vCPU and 0.5 GB of RAM. You can optionally configure a higher spec machine which will increase the cost of running the task but can also improve the performance of the task if it is CPU or memory bound.
56+
57+
See the [machine configurations](/machines#machine-configurations) for more details.

docs/machines.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ export const config: TriggerConfig = {
3030

3131
## Machine configurations
3232

33-
| Preset | vCPU | Memory |
34-
| --------- | ---- | ------ |
35-
| micro | 0.25 | 0.25 |
36-
| small-1x | 0.5 | 0.5 |
37-
| small-2x | 1 | 1 |
38-
| medium-1x | 1 | 2 |
39-
| medium-2x | 2 | 4 |
40-
| large-1x | 4 | 8 |
41-
| large-2x | 8 | 16 |
33+
| Preset | vCPU | Memory | Disk space |
34+
| ------------------- | ---- | ------ | ---------- |
35+
| micro | 0.25 | 0.25 | 10GB |
36+
| small-1x (default) | 0.5 | 0.5 | 10GB |
37+
| small-2x | 1 | 1 | 10GB |
38+
| medium-1x | 1 | 2 | 10GB |
39+
| medium-2x | 2 | 4 | 10GB |
40+
| large-1x | 4 | 8 | 10GB |
41+
| large-2x | 8 | 16 | 10GB |
4242

4343
You can view the Trigger.dev cloud pricing for these machines [here](https://trigger.dev/pricing#computePricing).

docs/migration-defer.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export async function runLongRunningTask() {
240240
to trigger tasks from your code. See the [API keys page](/apikeys) for more information.
241241
</Warning>
242242

243-
#### Example 2: A CRON task
243+
#### Example 2: A cron task
244244

245245
We call these [scheduled tasks](/tasks-scheduled) in Trigger.dev.
246246

docs/mint.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
},
4444
"topbarLinks": [
4545
{
46-
"name": "Community",
46+
"name": "v2 docs",
47+
"url": "https://v2docs.trigger.dev/documentation/introduction"
48+
},
49+
{
50+
"name": "Discord",
4751
"url": "https://trigger.dev/discord"
4852
}
4953
],
@@ -85,10 +89,8 @@
8589
"tasks-overview",
8690
"triggering",
8791
"apikeys",
88-
{
89-
"group": "Task types",
90-
"pages": ["tasks-regular", "tasks-scheduled"]
91-
},
92+
"tasks-regular",
93+
"tasks-scheduled",
9294
"trigger-config"
9395
]
9496
},

docs/snippets/step-run-test.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<Step title="Perform a test run using the dashboard">
22

3-
The CLI `dev` command spits out various useful URLs. Right now we want to visit the Test page it provided.
3+
The CLI `dev` command spits out various useful URLs. Right now we want to visit the Test page <Icon icon="circle-1" iconType="solid" size={20} color="F43F47" />.
44

5-
You should see our Example task in the list, select it. Most tasks have a "payload" which you enter in the JSON editor, but our example task doesn't need any input.
5+
You should see our Example task in the list <Icon icon="circle-2" iconType="solid" size={20} color="F43F47" />, select it. Most tasks have a "payload" which you enter in the JSON editor <Icon icon="circle-3" iconType="solid" size={20} color="F43F47" />, but our example task doesn't need any input.
66

7-
Press the "Run test" button.
7+
Press the "Run test" button <Icon icon="circle-4" iconType="solid" size={20} color="F43F47" />.
8+
9+
![Test page](/images/test-page.png)
810

911
</Step>

docs/snippets/step-view-run.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Congratulations, you should see the run page which will live reload showing you the current state of the run.
44

5-
If you go back to your terminal you'll see that the dev command also shows tasks that are running and links to the run log.
5+
![Run page](/images/run-page.png)
6+
7+
If you go back to your terminal you'll see that the dev command also shows the task status and links to the run log.
8+
9+
![Terminal showing completed run](/images/terminal-completed-run.png)
610

711
</Step>

docs/tasks-overview.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ export const heavyTask = task({
121121
});
122122
```
123123

124+
## Lifecycle functions
125+
126+
![Lifecycle functions](/images/lifecycle-functions.png)
127+
124128
### `init` function
125129

126130
This function is called before a run attempt:

docs/tasks-scheduled.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "Scheduled tasks"
3-
description: "A task that is triggered on a recurring schedule using CRON syntax."
2+
title: "Scheduled tasks (cron)"
3+
description: "A task that is triggered on a recurring schedule using cron syntax."
44
---
55

66
## Defining a scheduled task
@@ -120,7 +120,7 @@ To use imperative schedules you need to do two things:
120120
1. Define a task in your code using `schedules.task()`.
121121
2. Attach 1+ schedules to the task either using the dashboard or the SDK.
122122

123-
## Supported CRON syntax
123+
## Supported cron syntax
124124

125125
```
126126
* * * * *
@@ -135,7 +135,7 @@ To use imperative schedules you need to do two things:
135135

136136
"L" means the last. In the "day of week" field, 1L means the last Monday of the month. In the "day of month" field, L means the last day of the month.
137137

138-
We do not support seconds in the CRON syntax.
138+
We do not support seconds in the cron syntax.
139139

140140
## When schedules won't trigger
141141

@@ -165,7 +165,7 @@ These are the options when creating a schedule:
165165
| Name | Description |
166166
| ----------------- | --------------------------------------------------------------------------------------------- |
167167
| Task | The id of the task you want to attach to. |
168-
| CRON pattern | The schedule in CRON format. |
168+
| Cron pattern | The schedule in cron format. |
169169
| Timezone | The timezone the schedule will run in. Defaults to "UTC" |
170170
| External id | An optional external id, usually you'd use a userId. |
171171
| Deduplication key | An optional deduplication key. If you pass the same value, it will update rather than create. |
@@ -183,7 +183,7 @@ You call `schedules.create()` to create a schedule from your code. Here's the si
183183
const createdSchedule = await schedules.create({
184184
//The id of the scheduled task you want to attach to.
185185
task: firstScheduledTask.id,
186-
//The schedule in CRON format.
186+
//The schedule in cron format.
187187
cron: "0 0 * * *",
188188
//this is required, it prevents you from creating duplicate schedules. It will update the schedule if it already exists.
189189
deduplicationKey: "my-deduplication-key",
@@ -200,14 +200,14 @@ This means you can have thousands of schedules attached to a single task, but on
200200
const createdSchedule = await schedules.create({
201201
//The id of the scheduled task you want to attach to.
202202
task: firstScheduledTask.id,
203-
//The schedule in CRON format.
203+
//The schedule in cron format.
204204
cron: "0 0 * * *",
205205
// Optional, it defaults to "UTC". In IANA format, e.g. "America/New_York".
206206
// In this case, the task will run at midnight every day in New York time.
207207
// If you specify a timezone it will automatically work with daylight saving time.
208208
timezone: "America/New_York",
209209
//Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task.
210-
//This allows you to have per-user CRON tasks.
210+
//This allows you to have per-user cron tasks.
211211
externalId: "user_123456",
212212
//You can only create one schedule with this key.
213213
//If you use it twice, the second call will update the schedule.

docs/triggering.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ await myTask.trigger({ some: "data" }, { delay: "1h52m18s" });
446446
await myTask.trigger({ some: "data" }, { delay: "2024-12-01T00:00:00" });
447447
// Delay using a Date object
448448
await myTask.trigger({ some: "data" }, { delay: new Date(Date.now() + 1000 * 60 * 60) });
449+
// Delay using a timezone
450+
await myTask.trigger({ some: "data" }, { delay: new Date('2024-07-23T11:50:00+02:00') });
449451
```
450452

451453
Runs that are delayed and have not been enqueued yet will display in the dashboard with a "Delayed" status:

docs/troubleshooting.mdx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,29 @@ title: "Common problems"
33
description: "Some common problems you might experience and their solutions"
44
---
55

6+
## Development
7+
8+
### `EACCES: permission denied`
9+
10+
If you see this error:
11+
12+
```ts
13+
6090 verbose stack Error: EACCES: permission denied, rename '/Users/user/.npm/_cacache/tmp/f1bfea11' -> '/Users/user/.npm/_cacache/content-v2/sha512/31/d8/e094a47a0105d06fd246892ed1736c02eae323726ec6a3f34734eeb71308895dfba4f4f82a88ffe7e480c90b388c91fc3d9f851ba7b96db4dc33fbc65528'
14+
```
15+
16+
First, clear the npm cache:
17+
18+
```ts
19+
npm cache clean --force
20+
```
21+
22+
Then change the permissions of the npm folder (if 1 doesn't work):
23+
24+
```ts
25+
sudo chown -R $(whoami) ~/.npm
26+
```
27+
28+
629
## Deployment
730

831
Running the [trigger.dev deploy] command builds and deploys your code. Sometimes there can be issues building your code.
@@ -82,6 +105,10 @@ Prisma uses code generation to create the client from your schema file. This mea
82105

83106
Make sure that you always use `await` when you call `trigger`, `triggerAndWait`, `batchTrigger`, and `batchTriggerAndWait`. If you don't then it's likely the task(s) won't be triggered because the calling function process can be terminated before the networks calls are sent.
84107

108+
### `Error: Prisma generate failed to find the specified schema at ../../path`
109+
110+
111+
85112
## Framework specific issues
86113

87114
### NestJS swallows all errors/exceptions
@@ -102,3 +129,28 @@ export const simplestTask = task({
102129
```
103130

104131
NestJS has a global exception filter that catches all errors and swallows them, so we can't receive them. Our current recommendation is to not use NestJS inside your tasks. If you're a NestJS user you can still use Trigger.dev but just don't use NestJS inside your tasks like this.
132+
133+
### React is not defined
134+
135+
If you see this error:
136+
137+
```ts
138+
Worker failed to start ReferenceError: React is not defined
139+
```
140+
141+
Either add this to your file:
142+
143+
```ts
144+
import React from "react";
145+
```
146+
147+
Or change the tsconfig jsx setting:
148+
149+
```json
150+
{
151+
"compilerOptions": {
152+
//...
153+
"jsx": "react-jsx"
154+
},
155+
}
156+
```

docs/wait-for.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ export const veryLongTask = task({
2828
});
2929
```
3030

31-
This allows you to write linear code without having to worry about the complexity of scheduling or managing CRON jobs.
31+
This allows you to write linear code without having to worry about the complexity of scheduling or managing cron jobs.
3232

3333
<PausedExecutionFree />

docs/wait-until.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const sendReminderEmail = task({
2525
});
2626
```
2727

28-
This allows you to write linear code without having to worry about the complexity of scheduling or managing CRON jobs.
28+
This allows you to write linear code without having to worry about the complexity of scheduling or managing cron jobs.
2929

3030
<PausedExecutionFree />
3131

0 commit comments

Comments
 (0)