diff --git a/apps/webapp/app/routes/resources.orgs.$organizationSlug.select-plan.tsx b/apps/webapp/app/routes/resources.orgs.$organizationSlug.select-plan.tsx index 85ff370b0..dac05d219 100644 --- a/apps/webapp/app/routes/resources.orgs.$organizationSlug.select-plan.tsx +++ b/apps/webapp/app/routes/resources.orgs.$organizationSlug.select-plan.tsx @@ -119,7 +119,7 @@ const pricingDefinitions = { }, schedules: { title: "Schedules", - content: "You can attach recurring schedules to tasks using CRON syntax.", + content: "You can attach recurring schedules to tasks using cron syntax.", }, alerts: { title: "Alert destination", diff --git a/docs/apikeys.mdx b/docs/apikeys.mdx index 1cfbd0a4c..9d4df925c 100644 --- a/docs/apikeys.mdx +++ b/docs/apikeys.mdx @@ -15,14 +15,14 @@ Each environment has its own secret key. You can find the value on the API keys 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`). -```bash -export TRIGGER_SECRET_KEY=tr_dev_… +```bash .env +TRIGGER_SECRET_KEY="tr_dev_…" ``` You can do the same if you are self-hosting and need to change the default URL by using `TRIGGER_API_URL`. -```bash -export TRIGGER_API_URL=https://trigger.example.com +```bash .env +TRIGGER_API_URL="https://trigger.example.com" ``` The default URL is `https://api.trigger.dev`. diff --git a/docs/cli-dev.mdx b/docs/cli-dev.mdx index 26f4e373a..ae85cb674 100644 --- a/docs/cli-dev.mdx +++ b/docs/cli-dev.mdx @@ -48,3 +48,46 @@ yarn dlx trigger.dev@beta dev --debugger ``` + +### Concurrently running the terminal + +The concurrently package allows you to run multiple package.json scripts at the same time – in this case, your site and Trigger.dev. + + + + + + + +```bash npm +npm i concurrently -D +``` + +```bash pnpm +pnpm i concurrently -D +``` + +```bash yarn +yarn i concurrently -D +``` + + + + + + + +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: + +```json +"scripts": { + "dev": "concurrently --raw --kill-others npm:dev:*", + "dev:next": "next dev", + "dev:trigger": "npx trigger.dev@beta dev", + //... +} +``` + + + + \ No newline at end of file diff --git a/docs/github-actions.mdx b/docs/github-actions.mdx index adcf89e35..1a9206ea3 100644 --- a/docs/github-actions.mdx +++ b/docs/github-actions.mdx @@ -77,20 +77,19 @@ jobs: If you already have a GitHub action file, you can just add the final step "🚀 Deploy Trigger.dev" to your existing file. -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. +### Creating a Personal Access Token -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. + - - 1. Go to your repository on GitHub. - 2. Click on "Settings". - 3. Click on "Secrets and variables" -> "Actions" - 4. Click on "New repository secret". - 5. Add the name `TRIGGER_ACCESS_TOKEN` and the value of your access token. +Go to your profile page and click on the ["Personal Access Tokens"](https://cloud.trigger.dev/account/tokens) tab. + +Click on 'Settings' -> 'Secrets and variables' -> 'Actions' -> 'New repository secret' + +Add the name `TRIGGER_ACCESS_TOKEN` and the value of your access token. ![Add TRIGGER_ACCESS_TOKEN in GitHub](/images/github-access-token.png) + + -![Add TRIGGER_ACCESS_TOKEN in GitHub](/images/github-access-token.png) - ## Version pinning diff --git a/docs/images/lifecycle-functions.png b/docs/images/lifecycle-functions.png new file mode 100644 index 000000000..b99e06a9e Binary files /dev/null and b/docs/images/lifecycle-functions.png differ diff --git a/docs/images/run-page.png b/docs/images/run-page.png new file mode 100644 index 000000000..aa895555b Binary files /dev/null and b/docs/images/run-page.png differ diff --git a/docs/images/terminal-completed-run.png b/docs/images/terminal-completed-run.png new file mode 100644 index 000000000..805e32fda Binary files /dev/null and b/docs/images/terminal-completed-run.png differ diff --git a/docs/images/test-page.png b/docs/images/test-page.png new file mode 100644 index 000000000..e70028399 Binary files /dev/null and b/docs/images/test-page.png differ diff --git a/docs/limits.mdx b/docs/limits.mdx index 43bce02da..c1b340044 100644 --- a/docs/limits.mdx +++ b/docs/limits.mdx @@ -49,3 +49,9 @@ If you're creating schedules for your user you will definitely need to request m | Task outputs | Must not exceed 10MB | 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. + +### Machines + +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. + +See the [machine configurations](/machines#machine-configurations) for more details. \ No newline at end of file diff --git a/docs/machines.mdx b/docs/machines.mdx index 84a113a61..bc980384b 100644 --- a/docs/machines.mdx +++ b/docs/machines.mdx @@ -30,14 +30,14 @@ export const config: TriggerConfig = { ## Machine configurations -| Preset | vCPU | Memory | -| --------- | ---- | ------ | -| micro | 0.25 | 0.25 | -| small-1x | 0.5 | 0.5 | -| small-2x | 1 | 1 | -| medium-1x | 1 | 2 | -| medium-2x | 2 | 4 | -| large-1x | 4 | 8 | -| large-2x | 8 | 16 | +| Preset | vCPU | Memory | Disk space | +| ------------------- | ---- | ------ | ---------- | +| micro | 0.25 | 0.25 | 10GB | +| small-1x (default) | 0.5 | 0.5 | 10GB | +| small-2x | 1 | 1 | 10GB | +| medium-1x | 1 | 2 | 10GB | +| medium-2x | 2 | 4 | 10GB | +| large-1x | 4 | 8 | 10GB | +| large-2x | 8 | 16 | 10GB | You can view the Trigger.dev cloud pricing for these machines [here](https://trigger.dev/pricing#computePricing). diff --git a/docs/migration-defer.mdx b/docs/migration-defer.mdx index fddd6a9fe..3ccc16587 100644 --- a/docs/migration-defer.mdx +++ b/docs/migration-defer.mdx @@ -240,7 +240,7 @@ export async function runLongRunningTask() { to trigger tasks from your code. See the [API keys page](/apikeys) for more information. -#### Example 2: A CRON task +#### Example 2: A cron task We call these [scheduled tasks](/tasks-scheduled) in Trigger.dev. diff --git a/docs/mint.json b/docs/mint.json index c427d7a8c..6586897a1 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -43,7 +43,11 @@ }, "topbarLinks": [ { - "name": "Community", + "name": "v2 docs", + "url": "https://v2docs.trigger.dev/documentation/introduction" + }, + { + "name": "Discord", "url": "https://trigger.dev/discord" } ], @@ -85,10 +89,8 @@ "tasks-overview", "triggering", "apikeys", - { - "group": "Task types", - "pages": ["tasks-regular", "tasks-scheduled"] - }, + "tasks-regular", + "tasks-scheduled", "trigger-config" ] }, diff --git a/docs/snippets/step-run-test.mdx b/docs/snippets/step-run-test.mdx index a00946447..5bf8b2f5b 100644 --- a/docs/snippets/step-run-test.mdx +++ b/docs/snippets/step-run-test.mdx @@ -1,9 +1,11 @@ -The CLI `dev` command spits out various useful URLs. Right now we want to visit the Test page it provided. +The CLI `dev` command spits out various useful URLs. Right now we want to visit the Test page . -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. +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. -Press the "Run test" button. +Press the "Run test" button . + +![Test page](/images/test-page.png) diff --git a/docs/snippets/step-view-run.mdx b/docs/snippets/step-view-run.mdx index 9bd5d73cf..8a5439840 100644 --- a/docs/snippets/step-view-run.mdx +++ b/docs/snippets/step-view-run.mdx @@ -2,6 +2,10 @@ Congratulations, you should see the run page which will live reload showing you the current state of the run. -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. +![Run page](/images/run-page.png) + +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. + +![Terminal showing completed run](/images/terminal-completed-run.png) diff --git a/docs/tasks-overview.mdx b/docs/tasks-overview.mdx index 3c54b59a8..2ed8f0b88 100644 --- a/docs/tasks-overview.mdx +++ b/docs/tasks-overview.mdx @@ -121,6 +121,10 @@ export const heavyTask = task({ }); ``` +## Lifecycle functions + +![Lifecycle functions](/images/lifecycle-functions.png) + ### `init` function This function is called before a run attempt: diff --git a/docs/tasks-scheduled.mdx b/docs/tasks-scheduled.mdx index 601d7b2e9..c9f722173 100644 --- a/docs/tasks-scheduled.mdx +++ b/docs/tasks-scheduled.mdx @@ -1,6 +1,6 @@ --- -title: "Scheduled tasks" -description: "A task that is triggered on a recurring schedule using CRON syntax." +title: "Scheduled tasks (cron)" +description: "A task that is triggered on a recurring schedule using cron syntax." --- ## Defining a scheduled task @@ -120,7 +120,7 @@ To use imperative schedules you need to do two things: 1. Define a task in your code using `schedules.task()`. 2. Attach 1+ schedules to the task either using the dashboard or the SDK. -## Supported CRON syntax +## Supported cron syntax ``` * * * * * @@ -135,7 +135,7 @@ To use imperative schedules you need to do two things: "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. -We do not support seconds in the CRON syntax. +We do not support seconds in the cron syntax. ## When schedules won't trigger @@ -165,7 +165,7 @@ These are the options when creating a schedule: | Name | Description | | ----------------- | --------------------------------------------------------------------------------------------- | | Task | The id of the task you want to attach to. | -| CRON pattern | The schedule in CRON format. | +| Cron pattern | The schedule in cron format. | | Timezone | The timezone the schedule will run in. Defaults to "UTC" | | External id | An optional external id, usually you'd use a userId. | | 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 const createdSchedule = await schedules.create({ //The id of the scheduled task you want to attach to. task: firstScheduledTask.id, - //The schedule in CRON format. + //The schedule in cron format. cron: "0 0 * * *", //this is required, it prevents you from creating duplicate schedules. It will update the schedule if it already exists. deduplicationKey: "my-deduplication-key", @@ -200,14 +200,14 @@ This means you can have thousands of schedules attached to a single task, but on const createdSchedule = await schedules.create({ //The id of the scheduled task you want to attach to. task: firstScheduledTask.id, - //The schedule in CRON format. + //The schedule in cron format. cron: "0 0 * * *", // Optional, it defaults to "UTC". In IANA format, e.g. "America/New_York". // In this case, the task will run at midnight every day in New York time. // If you specify a timezone it will automatically work with daylight saving time. timezone: "America/New_York", //Optionally, you can specify your own IDs (like a user ID) and then use it inside the run function of your task. - //This allows you to have per-user CRON tasks. + //This allows you to have per-user cron tasks. externalId: "user_123456", //You can only create one schedule with this key. //If you use it twice, the second call will update the schedule. diff --git a/docs/triggering.mdx b/docs/triggering.mdx index 527002757..b43a74ac9 100644 --- a/docs/triggering.mdx +++ b/docs/triggering.mdx @@ -446,6 +446,8 @@ await myTask.trigger({ some: "data" }, { delay: "1h52m18s" }); await myTask.trigger({ some: "data" }, { delay: "2024-12-01T00:00:00" }); // Delay using a Date object await myTask.trigger({ some: "data" }, { delay: new Date(Date.now() + 1000 * 60 * 60) }); +// Delay using a timezone +await myTask.trigger({ some: "data" }, { delay: new Date('2024-07-23T11:50:00+02:00') }); ``` Runs that are delayed and have not been enqueued yet will display in the dashboard with a "Delayed" status: diff --git a/docs/troubleshooting.mdx b/docs/troubleshooting.mdx index 3fb2a9501..0dd5871ba 100644 --- a/docs/troubleshooting.mdx +++ b/docs/troubleshooting.mdx @@ -3,6 +3,29 @@ title: "Common problems" description: "Some common problems you might experience and their solutions" --- +## Development + +### `EACCES: permission denied` + +If you see this error: + +```ts +6090 verbose stack Error: EACCES: permission denied, rename '/Users/user/.npm/_cacache/tmp/f1bfea11' -> '/Users/user/.npm/_cacache/content-v2/sha512/31/d8/e094a47a0105d06fd246892ed1736c02eae323726ec6a3f34734eeb71308895dfba4f4f82a88ffe7e480c90b388c91fc3d9f851ba7b96db4dc33fbc65528' +``` + +First, clear the npm cache: + +```ts +npm cache clean --force +``` + +Then change the permissions of the npm folder (if 1 doesn't work): + +```ts +sudo chown -R $(whoami) ~/.npm +``` + + ## Deployment 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 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. +### `Error: Prisma generate failed to find the specified schema at ../../path` + + + ## Framework specific issues ### NestJS swallows all errors/exceptions @@ -102,3 +129,28 @@ export const simplestTask = task({ ``` 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. + +### React is not defined + +If you see this error: + +```ts +Worker failed to start ReferenceError: React is not defined +``` + +Either add this to your file: + +```ts +import React from "react"; +``` + +Or change the tsconfig jsx setting: + +```json +{ + "compilerOptions": { + //... + "jsx": "react-jsx" + }, +} +``` \ No newline at end of file diff --git a/docs/wait-for.mdx b/docs/wait-for.mdx index f88a3e8f5..f8c1ea10c 100644 --- a/docs/wait-for.mdx +++ b/docs/wait-for.mdx @@ -28,6 +28,6 @@ export const veryLongTask = task({ }); ``` -This allows you to write linear code without having to worry about the complexity of scheduling or managing CRON jobs. +This allows you to write linear code without having to worry about the complexity of scheduling or managing cron jobs. diff --git a/docs/wait-until.mdx b/docs/wait-until.mdx index 2b88fc53a..adfb983b8 100644 --- a/docs/wait-until.mdx +++ b/docs/wait-until.mdx @@ -25,7 +25,7 @@ export const sendReminderEmail = task({ }); ``` -This allows you to write linear code without having to worry about the complexity of scheduling or managing CRON jobs. +This allows you to write linear code without having to worry about the complexity of scheduling or managing cron jobs.