Skip to content

Docs/various docs improvements #1716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions docs/config/config-file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,12 @@ This is usually required if you are using certain ORMs, like TypeORM, that requi

If you are using Prisma, you should use the prisma build extension.

- Automatically handles copying prisma files to the build directory.
- Generates the prisma client during the deploy process
- Automatically handles copying Prisma files to the build directory
- Generates the Prisma client during the deploy process
- Optionally will migrate the database during the deploy process
- Support for TypedSQL and multiple schema files.
- Support for TypedSQL and multiple schema files
- You can use `prismaSchemaFolder` to specify just the directory containing your schema file, instead of the full path
- You can add the extension twice if you have multiple separate schemas in the same project (example below)

You can use it for a simple Prisma setup like this:

Expand Down Expand Up @@ -522,6 +524,21 @@ These environment variables are only used during the build process and are not e

</Note>

If you have multiple separate schemas in the same project you can add the extension multiple times:

```ts
prismaExtension({
schema: 'prisma/schema/main.prisma',
version: '6.2.0',
migrate: false,
}),
prismaExtension({
schema: 'prisma/schema/secondary.prisma',
version: '6.2.0',
migrate: false,
}),
```

#### syncEnvVars

The `syncEnvVars` build extension replaces the deprecated `resolveEnvVars` export. Check out our [syncEnvVars documentation](/deploy-environment-variables#sync-env-vars-from-another-service) for more information.
Expand Down
8 changes: 8 additions & 0 deletions docs/idempotency.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ await tasks.batchTrigger("my-task", [

## `idempotencyKeyTTL` option

The `idempotencyKeyTTL` option defines a time window during which a task with the same idempotency key will only run once. Here's how it works:

1. When you trigger a task with an idempotency key and set `idempotencyKeyTTL: "5m"`, it creates a 5-minute window.
2. During this window, any subsequent triggers with the same idempotency key will return the original task run instead of creating a new one.
3. Once the TTL window expires, the next trigger with that idempotency key will create a new task run and start a new time window.

![idempotency-key-ttl](/images/idempotency-key-ttl.png)

By default idempotency keys are stored for 30 days. You can change this by passing the `idempotencyKeyTTL` option when triggering a task:

```ts
Expand Down
Binary file added docs/images/idempotency-key-ttl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/limits.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ We limit the size of logs to prevent oversized data potentially causing issues.

## Alerts

An alert destination is a single email address, Slack channel, or webhook URL that you want to send alerts to. If you're on the Pro and need more than 100 alert destinations, you can request more by contacting us via [email](https://trigger.dev/contact) or [Discord](https://trigger.dev/discord).
An alert destination is a single email address, Slack channel, or webhook URL that you want to send alerts to. If you're on the Pro plan and need more than the plan limit, you can request more by contacting us via [email](https://trigger.dev/contact) or [Discord](https://trigger.dev/discord).

| Pricing tier | Limit |
| :----------- | :---------------------- |
Expand Down
4 changes: 3 additions & 1 deletion docs/runs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ You can set a TTL when triggering a run:
await yourTask.trigger({ foo: "bar" }, { ttl: "10m" });
```

If the run hasn't started within the specified TTL, it will automatically expire. This is useful for time-sensitive tasks. Note that dev runs automatically have a 10-minute TTL.
If the run hasn't started within the specified TTL, it will automatically expire, returning the status `Expired`. This is useful for time-sensitive tasks where immediate execution is important. For example, when you queue many runs simultaneously and exceed your concurrency limits, some runs might be delayed - using TTL ensures they only execute if they can start within your specified timeframe.

Note that dev runs automatically have a 10-minute TTL. In Staging and Production environments, no TTL is set by default.

![Run with TTL](/images/run-with-ttl.png)

Expand Down
289 changes: 289 additions & 0 deletions docs/troubleshooting-alerts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,292 @@ export async function action({ request }: ActionFunctionArgs) {
}
}
```

### Common properties

When you create a webhook alert, you'll receive different payloads depending on the type of alert. All webhooks share some common properties:

<ParamField path="id" type="string">
A unique identifier for this webhook event
</ParamField>

<ParamField path="created" type="datetime">
When this webhook event was created
</ParamField>

<ParamField path="webhookVersion" type="string">
The version of the webhook payload format
</ParamField>

<ParamField path="type" type="string">
The type of alert webhook. One of: `alert.run.failed`, `alert.deployment.success`, or `alert.deployment.failed`
</ParamField>

### Run Failed Alert

This webhook is sent when a run fails. The payload is available on the `object` property:

<ParamField path="object.task.id" type="string">
Unique identifier for the task
</ParamField>

<ParamField path="object.task.filePath" type="string">
File path where the task is defined
</ParamField>

<ParamField path="object.task.exportName" type="string">
Name of the exported task function
</ParamField>

<ParamField path="object.task.version" type="string">
Version of the task
</ParamField>

<ParamField path="object.task.sdkVersion" type="string">
Version of the SDK used
</ParamField>

<ParamField path="object.task.cliVersion" type="string">
Version of the CLI used
</ParamField>

<ParamField path="object.run.id" type="string">
Unique identifier for the run
</ParamField>

<ParamField path="object.run.number" type="number">
Run number
</ParamField>

<ParamField path="object.run.status" type="string">
Current status of the run
</ParamField>

<ParamField path="object.run.createdAt" type="datetime">
When the run was created
</ParamField>

<ParamField path="object.run.startedAt" type="datetime">
When the run started executing
</ParamField>

<ParamField path="object.run.completedAt" type="datetime">
When the run finished executing
</ParamField>

<ParamField path="object.run.isTest" type="boolean">
Whether this is a test run
</ParamField>

<ParamField path="object.run.idempotencyKey" type="string">
Idempotency key for the run
</ParamField>

<ParamField path="object.run.tags" type="string[]">
Associated tags
</ParamField>

<ParamField path="object.run.error" type="object">
Error information
</ParamField>

<ParamField path="object.run.isOutOfMemoryError" type="boolean">
Whether the run was an out-of-memory error
</ParamField>

<ParamField path="object.run.machine" type="string">
Machine preset used for the run
</ParamField>

<ParamField path="object.run.dashboardUrl" type="string">
URL to view the run in the dashboard
</ParamField>

<ParamField path="object.environment.id" type="string">
Environment ID
</ParamField>

<ParamField path="object.environment.type" type="string">
Environment type (STAGING or PRODUCTION)
</ParamField>

<ParamField path="object.environment.slug" type="string">
Environment slug
</ParamField>

<ParamField path="object.organization.id" type="string">
Organization ID
</ParamField>

<ParamField path="object.organization.slug" type="string">
Organization slug
</ParamField>

<ParamField path="object.organization.name" type="string">
Organization name
</ParamField>

<ParamField path="object.project.id" type="string">
Project ID
</ParamField>

<ParamField path="object.project.ref" type="string">
Project reference
</ParamField>

<ParamField path="object.project.slug" type="string">
Project slug
</ParamField>

<ParamField path="object.project.name" type="string">
Project name
</ParamField>

### Deployment Success Alert

This webhook is sent when a deployment succeeds. The payload is available on the `object` property:

<ParamField path="object.deployment.id" type="string">
Deployment ID
</ParamField>

<ParamField path="object.deployment.status" type="string">
Deployment status
</ParamField>

<ParamField path="object.deployment.version" type="string">
Deployment version
</ParamField>

<ParamField path="object.deployment.shortCode" type="string">
Short code identifier
</ParamField>

<ParamField path="object.deployment.deployedAt" type="datetime">
When the deployment completed
</ParamField>

<ParamField path="object.tasks" type="array">
Array of deployed tasks with properties: id, filePath, exportName, and triggerSource
</ParamField>

<ParamField path="object.environment.id" type="string">
Environment ID
</ParamField>

<ParamField path="object.environment.type" type="string">
Environment type (STAGING or PRODUCTION)
</ParamField>

<ParamField path="object.environment.slug" type="string">
Environment slug
</ParamField>

<ParamField path="object.organization.id" type="string">
Organization ID
</ParamField>

<ParamField path="object.organization.slug" type="string">
Organization slug
</ParamField>

<ParamField path="object.organization.name" type="string">
Organization name
</ParamField>

<ParamField path="object.project.id" type="string">
Project ID
</ParamField>

<ParamField path="object.project.ref" type="string">
Project reference
</ParamField>

<ParamField path="object.project.slug" type="string">
Project slug
</ParamField>

<ParamField path="object.project.name" type="string">
Project name
</ParamField>

### Deployment Failed Alert

This webhook is sent when a deployment fails. The payload is available on the `object` property:

<ParamField path="object.deployment.id" type="string">
Deployment ID
</ParamField>

<ParamField path="object.deployment.status" type="string">
Deployment status
</ParamField>

<ParamField path="object.deployment.version" type="string">
Deployment version
</ParamField>

<ParamField path="object.deployment.shortCode" type="string">
Short code identifier
</ParamField>

<ParamField path="object.deployment.failedAt" type="datetime">
When the deployment failed
</ParamField>

<ParamField path="object.error.name" type="string">
Error name
</ParamField>

<ParamField path="object.error.message" type="string">
Error message
</ParamField>

<ParamField path="object.error.stack" type="string">
Error stack trace (optional)
</ParamField>

<ParamField path="object.error.stderr" type="string">
Standard error output (optional)
</ParamField>

<ParamField path="object.environment.id" type="string">
Environment ID
</ParamField>

<ParamField path="object.environment.type" type="string">
Environment type (STAGING or PRODUCTION)
</ParamField>

<ParamField path="object.environment.slug" type="string">
Environment slug
</ParamField>

<ParamField path="object.organization.id" type="string">
Organization ID
</ParamField>

<ParamField path="object.organization.slug" type="string">
Organization slug
</ParamField>

<ParamField path="object.organization.name" type="string">
Organization name
</ParamField>

<ParamField path="object.project.id" type="string">
Project ID
</ParamField>

<ParamField path="object.project.ref" type="string">
Project reference
</ParamField>

<ParamField path="object.project.slug" type="string">
Project slug
</ParamField>

<ParamField path="object.project.name" type="string">
Project name
</ParamField>

Loading