From 457994d16a87d28d64bdeab9edd6ee3a564aec30 Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 11:47:25 +0000 Subject: [PATCH 1/9] =?UTF-8?q?Adds=20=E2=80=9CExplore=20by=20build=20exte?= =?UTF-8?q?nsion=E2=80=9D=20to=20the=20intro=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/introduction.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/introduction.mdx b/docs/introduction.mdx index 13474e0230..c8ed0f3480 100644 --- a/docs/introduction.mdx +++ b/docs/introduction.mdx @@ -85,6 +85,21 @@ We provide everything you need to build and manage background tasks: a CLI and S +## Explore by build extension + +| Extension | What it does | Docs | +|:----------|:------------|:--------------| +| prismaExtension | Use Prisma with Trigger.dev | [Learn more](/config/extensions/prismaExtension) | +| pythonExtension | Execute Python scripts in Trigger.dev | [Learn more](/config/extensions/pythonExtension) | +| puppeteer | Use Puppeteer with Trigger.dev | [Learn more](/config/extensions/puppeteer) | +| ffmpeg | Use FFmpeg with Trigger.dev | [Learn more](/config/extensions/ffmpeg) | +| aptGet | Install system packages with aptGet | [Learn more](/config/extensions/aptGet) | +| additionalFiles | Copy additional files to the build directory | [Learn more](/config/extensions/additionalFiles) | +| additionalPackages | Include additional packages in the build | [Learn more](/config/extensions/additionalPackages) | +| syncEnvVars | Automatically sync environment variables to Trigger.dev | [Learn more](/config/extensions/syncEnvVars) | +| esbuildPlugin | Add existing or custom esbuild plugins to your build process | [Learn more](/config/extensions/esbuildPlugin) | +| emitDecoratorMetadata | Support for the emitDecoratorMetadata TypeScript compiler | [Learn more](/config/extensions/emitDecoratorMetadata) | +| audioWaveform | Support for Audio Waveform in your project | [Learn more](/config/extensions/audioWaveform) | ## Getting help From 732c281dda0e4c5569d18d77557e413b9347305a Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 13:20:40 +0000 Subject: [PATCH 2/9] Adds instructions for clearing the build cache --- docs/troubleshooting.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/troubleshooting.mdx b/docs/troubleshooting.mdx index f67db8f14b..a2b322278b 100644 --- a/docs/troubleshooting.mdx +++ b/docs/troubleshooting.mdx @@ -29,6 +29,10 @@ Then change the permissions of the npm folder (if 1 doesn't work): sudo chown -R $(whoami) ~/.npm ``` +### Clear the build cache + +Ensure you have stopped your local dev server then locate the hidden `.trigger` folder in your project and delete it. You can then restart your local dev server. + ## Deployment Running the [trigger.dev deploy] command builds and deploys your code. Sometimes there can be issues building your code. From e36bcba3334d809e57c8ec0022ee6906a4b37fb2 Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 13:51:32 +0000 Subject: [PATCH 3/9] Add a tip for running trigger dev + next dev concurrently --- docs/guides/frameworks/nextjs.mdx | 4 ++++ .../run-dev-and-next-concurrently.mdx | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 docs/snippets/run-dev-and-next-concurrently.mdx diff --git a/docs/guides/frameworks/nextjs.mdx b/docs/guides/frameworks/nextjs.mdx index 80766cd7cc..675ce91611 100644 --- a/docs/guides/frameworks/nextjs.mdx +++ b/docs/guides/frameworks/nextjs.mdx @@ -19,6 +19,8 @@ import AddEnvironmentVariables from "/snippets/add-environment-variables.mdx"; import DeployingYourTask from "/snippets/deplopying-your-task.mdx"; import VercelDocsCards from "/snippets/vercel-docs-cards.mdx"; +import RunDevAndNextConcurrently from "/snippets/run-dev-and-next-concurrently.mdx"; + This guide can be followed for both App and Pages router as well as Server Actions. @@ -32,6 +34,8 @@ import VercelDocsCards from "/snippets/vercel-docs-cards.mdx"; + + ## Set your secret key locally Set your `TRIGGER_SECRET_KEY` environment variable in your `.env.local` file if using the Next.js App router or `.env` file if using Pages router. This key is used to authenticate with Trigger.dev, so you can trigger runs from your Next.js app. Visit the API Keys page in the dashboard and select the DEV secret key. diff --git a/docs/snippets/run-dev-and-next-concurrently.mdx b/docs/snippets/run-dev-and-next-concurrently.mdx new file mode 100644 index 0000000000..a2217bc6b5 --- /dev/null +++ b/docs/snippets/run-dev-and-next-concurrently.mdx @@ -0,0 +1,20 @@ + + Instead of running your Next.js app and Trigger.dev dev server in separate terminals, you can run them concurrently. First, add these scripts to your `package.json`: + + ```json + { + "scripts": { + "trigger:dev": "npx trigger.dev@latest dev", + "dev": "npx concurrently --kill-others --names \"next,trigger\" --prefix-colors \"yellow,blue\" \"next dev\" \"npm run trigger:dev\"" + } + } + ``` + + Then, in your terminal, you can start both servers with a single command: + + ```bash + npm run dev + ``` + + This will run both your Next.js app and Trigger.dev dev server in the same terminal window, with color-coded output to distinguish between them. + \ No newline at end of file From 629502c1ead0f48b7601f5a6c377ae9aa3b6d8ab Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 15:14:45 +0000 Subject: [PATCH 4/9] left align table headers --- docs/machines.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/machines.mdx b/docs/machines.mdx index 0282e5fb9c..486b4fef81 100644 --- a/docs/machines.mdx +++ b/docs/machines.mdx @@ -31,7 +31,7 @@ export const config: TriggerConfig = { ## Machine configurations | Preset | vCPU | Memory | Disk space | -| ------------------- | ---- | ------ | ---------- | +| :------------------ | :--- | :----- | :--------- | | micro | 0.25 | 0.25 | 10GB | | small-1x (default) | 0.5 | 0.5 | 10GB | | small-2x | 1 | 1 | 10GB | From f1c19e140181b6e889673e3eb73de8de881f6f5e Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 15:14:58 +0000 Subject: [PATCH 5/9] Adds trouble shooting for pino --- docs/troubleshooting.mdx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/troubleshooting.mdx b/docs/troubleshooting.mdx index a2b322278b..00ede4d061 100644 --- a/docs/troubleshooting.mdx +++ b/docs/troubleshooting.mdx @@ -67,6 +67,10 @@ export default defineConfig({ }); ``` +### `Cannot find module '/app/lib/worker.js"` when using pino + +If you see this error, add pino (and any other associated packages) to your `external` build settings in your `trigger.config.ts` file. Learn more about the `external` setting in the [config docs](/config/config-file#external). + ## Project setup issues ### `The requested module 'node:events' does not provide an export named 'addAbortListener'` From a1198c3c904e44374621d9d0f544a68f898120f1 Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 15:38:29 +0000 Subject: [PATCH 6/9] Adds corepack bug and workaround --- docs/deployment/overview.mdx | 3 +++ docs/snippets/corepack-error.mdx | 8 ++++++++ docs/troubleshooting.mdx | 4 ++++ 3 files changed, 15 insertions(+) create mode 100644 docs/snippets/corepack-error.mdx diff --git a/docs/deployment/overview.mdx b/docs/deployment/overview.mdx index 582d6b609c..d2c3b7e7e3 100644 --- a/docs/deployment/overview.mdx +++ b/docs/deployment/overview.mdx @@ -4,6 +4,8 @@ sidebarTitle: "Overview" description: "Learn how to deploy your tasks to Trigger.dev." --- +import CorepackError from "/snippets/corepack-error.mdx"; + Before you can run production workloads on Trigger.dev, you need to deploy your tasks. The only way to do this at the moment is through the [deploy CLI command](/cli-deploy): @@ -231,3 +233,4 @@ export default defineConfig({ }, }); ``` + \ No newline at end of file diff --git a/docs/snippets/corepack-error.mdx b/docs/snippets/corepack-error.mdx new file mode 100644 index 0000000000..e940899993 --- /dev/null +++ b/docs/snippets/corepack-error.mdx @@ -0,0 +1,8 @@ +### `Cannot find matching keyid` + +This error occurs when using Node.js v22 with corepack, as it's not yet compatible with the latest package manager signatures. To fix this, either: + +1. Downgrade to Node.js v20 (LTS), or +2. Install corepack globally: `npm i -g corepack@latest` + +The corepack bug and workaround are detailed in [this issue](https://github.com/npm/cli/issues/8075). \ No newline at end of file diff --git a/docs/troubleshooting.mdx b/docs/troubleshooting.mdx index 00ede4d061..40a80d9897 100644 --- a/docs/troubleshooting.mdx +++ b/docs/troubleshooting.mdx @@ -6,6 +6,7 @@ description: "Some common problems you might experience and their solutions" import NextjsTroubleshootingMissingApiKey from "/snippets/nextjs-missing-api-key.mdx"; import NextjsTroubleshootingButtonSyntax from "/snippets/nextjs-button-syntax.mdx"; import RateLimitHitUseBatchTrigger from "/snippets/rate-limit-hit-use-batchtrigger.mdx"; +import CorepackError from "/snippets/corepack-error.mdx"; ## Development @@ -71,6 +72,9 @@ export default defineConfig({ If you see this error, add pino (and any other associated packages) to your `external` build settings in your `trigger.config.ts` file. Learn more about the `external` setting in the [config docs](/config/config-file#external). + + + ## Project setup issues ### `The requested module 'node:events' does not provide an export named 'addAbortListener'` From 8004b8c522d1c26703987346c781a0ebeb96db26 Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 15:46:16 +0000 Subject: [PATCH 7/9] Removes reference to undici as it messes with spans --- docs/config/config-file.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/config/config-file.mdx b/docs/config/config-file.mdx index 2f013a03df..9d2607f95a 100644 --- a/docs/config/config-file.mdx +++ b/docs/config/config-file.mdx @@ -129,7 +129,6 @@ Some ones we recommend: | Package | Description | | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| `@opentelemetry/instrumentation-undici` | Logs all fetch calls (inc. Undici fetch) | | `@opentelemetry/instrumentation-http` | Logs all HTTP calls | | `@prisma/instrumentation` | Logs all Prisma calls, you need to [enable tracing](https://github.com/prisma/prisma/tree/main/packages/instrumentation) | | `@traceloop/instrumentation-openai` | Logs all OpenAI calls | From 00a63280947afc60a247f63f46d800d002aad96a Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 17:06:28 +0000 Subject: [PATCH 8/9] Left align table headers --- docs/logging.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/logging.mdx b/docs/logging.mdx index 7fc810f290..90ead35b94 100644 --- a/docs/logging.mdx +++ b/docs/logging.mdx @@ -38,9 +38,9 @@ Tracing is a way to follow the flow of your code. It's very useful for debugging Trigger.dev uses OpenTelemetry tracing under the hood. With automatic tracing for many things like task triggering, task attempts, HTTP requests, and more. | Name | Description | -| ------------- | -------------------------------- | -| Task triggers | Task triggers. | -| Task attempts | Task attempts. | +| :------------ | :------------------------------- | +| Task triggers | Task triggers | +| Task attempts | Task attempts | | HTTP requests | HTTP requests made by your code. | ### Adding instrumentations From f12fa08dec6087f111ff6a206d7f56cd5bca956a Mon Sep 17 00:00:00 2001 From: James Ritchie Date: Wed, 5 Mar 2025 17:22:31 +0000 Subject: [PATCH 9/9] Adds example for exporting logs to Axiom --- docs/config/config-file.mdx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/config/config-file.mdx b/docs/config/config-file.mdx index 9d2607f95a..0a8e3ba66a 100644 --- a/docs/config/config-file.mdx +++ b/docs/config/config-file.mdx @@ -137,6 +137,37 @@ Some ones we recommend: `@opentelemetry/instrumentation-fs` which logs all file system calls is currently not supported. +### Exporters + +You can also configure custom exporters to send your telemetry data to other services. For example, you can send your logs to [Axiom](https://axiom.co/docs/guides/opentelemetry-nodejs#exporter-instrumentation-ts): + +```ts trigger.config.ts +import { defineConfig } from "@trigger.dev/sdk/v3"; +import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; + +// Initialize OTLP trace exporter with the endpoint URL and headers +const axiomExporter = new OTLPTraceExporter({ + url: 'https://api.axiom.co/v1/traces', + headers: { + 'Authorization': `Bearer ${process.env.AXIOM_API_TOKEN}`, + 'X-Axiom-Dataset': process.env.AXIOM_DATASET + }, +}); + +export default defineConfig({ + project: "", + // Your other config settings... + telemetry: { + instrumentations: [ + // Your instrumentations here + ], + exporters: [axiomExporter], + }, +}); +``` + +Make sure to set the `AXIOM_API_TOKEN` and `AXIOM_DATASET` environment variables in your project. + ## Runtime We currently only officially support the `node` runtime, but you can try our experimental `bun` runtime by setting the `runtime` option in your config file: