@trigger.dev/sdk 4.5.0-rc.5 → 4.5.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/dist/commonjs/v3/ai.d.ts +178 -5
  2. package/dist/commonjs/v3/ai.js +603 -119
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/chat-client.js +3 -0
  5. package/dist/commonjs/v3/chat-client.js.map +1 -1
  6. package/dist/commonjs/v3/chat-react.js +10 -7
  7. package/dist/commonjs/v3/chat-react.js.map +1 -1
  8. package/dist/commonjs/v3/chat-server.d.ts +8 -0
  9. package/dist/commonjs/v3/chat-server.js +32 -10
  10. package/dist/commonjs/v3/chat-server.js.map +1 -1
  11. package/dist/commonjs/v3/chat-server.test.js +51 -0
  12. package/dist/commonjs/v3/chat-server.test.js.map +1 -1
  13. package/dist/commonjs/v3/chat.js +34 -6
  14. package/dist/commonjs/v3/chat.js.map +1 -1
  15. package/dist/commonjs/v3/chat.test.js +53 -0
  16. package/dist/commonjs/v3/chat.test.js.map +1 -1
  17. package/dist/commonjs/v3/createStartSessionAction.test.js +30 -0
  18. package/dist/commonjs/v3/createStartSessionAction.test.js.map +1 -1
  19. package/dist/commonjs/v3/sessions.d.ts +11 -6
  20. package/dist/commonjs/v3/sessions.js +10 -5
  21. package/dist/commonjs/v3/sessions.js.map +1 -1
  22. package/dist/commonjs/v3/test/mock-chat-agent.d.ts +6 -0
  23. package/dist/commonjs/v3/test/mock-chat-agent.js +1 -0
  24. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
  25. package/dist/commonjs/version.js +1 -1
  26. package/dist/esm/v3/ai.d.ts +178 -5
  27. package/dist/esm/v3/ai.js +603 -120
  28. package/dist/esm/v3/ai.js.map +1 -1
  29. package/dist/esm/v3/chat-client.js +3 -0
  30. package/dist/esm/v3/chat-client.js.map +1 -1
  31. package/dist/esm/v3/chat-react.js +10 -7
  32. package/dist/esm/v3/chat-react.js.map +1 -1
  33. package/dist/esm/v3/chat-server.d.ts +8 -0
  34. package/dist/esm/v3/chat-server.js +32 -10
  35. package/dist/esm/v3/chat-server.js.map +1 -1
  36. package/dist/esm/v3/chat-server.test.js +51 -0
  37. package/dist/esm/v3/chat-server.test.js.map +1 -1
  38. package/dist/esm/v3/chat.js +34 -6
  39. package/dist/esm/v3/chat.js.map +1 -1
  40. package/dist/esm/v3/chat.test.js +53 -0
  41. package/dist/esm/v3/chat.test.js.map +1 -1
  42. package/dist/esm/v3/createStartSessionAction.test.js +30 -0
  43. package/dist/esm/v3/createStartSessionAction.test.js.map +1 -1
  44. package/dist/esm/v3/sessions.d.ts +11 -6
  45. package/dist/esm/v3/sessions.js +10 -5
  46. package/dist/esm/v3/sessions.js.map +1 -1
  47. package/dist/esm/v3/test/mock-chat-agent.d.ts +6 -0
  48. package/dist/esm/v3/test/mock-chat-agent.js +1 -0
  49. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
  50. package/dist/esm/version.js +1 -1
  51. package/docs/ai/prompts.mdx +430 -0
  52. package/docs/ai-chat/actions.mdx +115 -0
  53. package/docs/ai-chat/anatomy.mdx +71 -0
  54. package/docs/ai-chat/backend.mdx +817 -0
  55. package/docs/ai-chat/background-injection.mdx +221 -0
  56. package/docs/ai-chat/changelog.mdx +850 -0
  57. package/docs/ai-chat/chat-local.mdx +174 -0
  58. package/docs/ai-chat/client-protocol.mdx +1081 -0
  59. package/docs/ai-chat/compaction.mdx +411 -0
  60. package/docs/ai-chat/custom-agents.mdx +364 -0
  61. package/docs/ai-chat/error-handling.mdx +415 -0
  62. package/docs/ai-chat/fast-starts.mdx +672 -0
  63. package/docs/ai-chat/frontend.mdx +580 -0
  64. package/docs/ai-chat/how-it-works.mdx +230 -0
  65. package/docs/ai-chat/lifecycle-hooks.mdx +530 -0
  66. package/docs/ai-chat/mcp.mdx +101 -0
  67. package/docs/ai-chat/overview.mdx +90 -0
  68. package/docs/ai-chat/patterns/branching-conversations.mdx +284 -0
  69. package/docs/ai-chat/patterns/code-sandbox.mdx +126 -0
  70. package/docs/ai-chat/patterns/database-persistence.mdx +414 -0
  71. package/docs/ai-chat/patterns/human-in-the-loop.mdx +275 -0
  72. package/docs/ai-chat/patterns/large-payloads.mdx +169 -0
  73. package/docs/ai-chat/patterns/oom-resilience.mdx +120 -0
  74. package/docs/ai-chat/patterns/persistence-and-replay.mdx +211 -0
  75. package/docs/ai-chat/patterns/recovery-boot.mdx +230 -0
  76. package/docs/ai-chat/patterns/skills.mdx +221 -0
  77. package/docs/ai-chat/patterns/sub-agents.mdx +383 -0
  78. package/docs/ai-chat/patterns/tool-result-auditing.mdx +148 -0
  79. package/docs/ai-chat/patterns/trusted-edge-signals.mdx +337 -0
  80. package/docs/ai-chat/patterns/version-upgrades.mdx +172 -0
  81. package/docs/ai-chat/pending-messages.mdx +343 -0
  82. package/docs/ai-chat/prompt-caching.mdx +206 -0
  83. package/docs/ai-chat/quick-start.mdx +161 -0
  84. package/docs/ai-chat/reference.mdx +909 -0
  85. package/docs/ai-chat/server-chat.mdx +263 -0
  86. package/docs/ai-chat/sessions.mdx +333 -0
  87. package/docs/ai-chat/testing.mdx +682 -0
  88. package/docs/ai-chat/tools.mdx +191 -0
  89. package/docs/ai-chat/types.mdx +242 -0
  90. package/docs/ai-chat/upgrade-guide.mdx +515 -0
  91. package/docs/apikeys.mdx +54 -0
  92. package/docs/building-with-ai.mdx +261 -0
  93. package/docs/bulk-actions.mdx +49 -0
  94. package/docs/changelog.mdx +6 -0
  95. package/docs/cli-deploy-commands.mdx +9 -0
  96. package/docs/cli-dev-commands.mdx +9 -0
  97. package/docs/cli-dev.mdx +8 -0
  98. package/docs/cli-init-commands.mdx +58 -0
  99. package/docs/cli-introduction.mdx +25 -0
  100. package/docs/cli-list-profiles-commands.mdx +42 -0
  101. package/docs/cli-login-commands.mdx +33 -0
  102. package/docs/cli-logout-commands.mdx +33 -0
  103. package/docs/cli-preview-archive.mdx +59 -0
  104. package/docs/cli-promote-commands.mdx +9 -0
  105. package/docs/cli-switch.mdx +43 -0
  106. package/docs/cli-update-commands.mdx +42 -0
  107. package/docs/cli-whoami-commands.mdx +33 -0
  108. package/docs/community.mdx +6 -0
  109. package/docs/config/config-file.mdx +602 -0
  110. package/docs/config/extensions/additionalFiles.mdx +38 -0
  111. package/docs/config/extensions/additionalPackages.mdx +40 -0
  112. package/docs/config/extensions/aptGet.mdx +34 -0
  113. package/docs/config/extensions/audioWaveform.mdx +20 -0
  114. package/docs/config/extensions/custom.mdx +380 -0
  115. package/docs/config/extensions/emitDecoratorMetadata.mdx +29 -0
  116. package/docs/config/extensions/esbuildPlugin.mdx +31 -0
  117. package/docs/config/extensions/ffmpeg.mdx +45 -0
  118. package/docs/config/extensions/lightpanda.mdx +56 -0
  119. package/docs/config/extensions/overview.mdx +67 -0
  120. package/docs/config/extensions/playwright.mdx +195 -0
  121. package/docs/config/extensions/prismaExtension.mdx +1014 -0
  122. package/docs/config/extensions/puppeteer.mdx +30 -0
  123. package/docs/config/extensions/pythonExtension.mdx +182 -0
  124. package/docs/config/extensions/syncEnvVars.mdx +291 -0
  125. package/docs/context.mdx +235 -0
  126. package/docs/database-connections.mdx +213 -0
  127. package/docs/deploy-environment-variables.mdx +435 -0
  128. package/docs/deployment/atomic-deployment.mdx +172 -0
  129. package/docs/deployment/overview.mdx +257 -0
  130. package/docs/deployment/preview-branches.mdx +224 -0
  131. package/docs/errors-retrying.mdx +379 -0
  132. package/docs/github-actions.mdx +222 -0
  133. package/docs/github-integration.mdx +136 -0
  134. package/docs/github-repo.mdx +8 -0
  135. package/docs/help-email.mdx +6 -0
  136. package/docs/help-slack.mdx +11 -0
  137. package/docs/hidden-tasks.mdx +56 -0
  138. package/docs/how-it-works.mdx +454 -0
  139. package/docs/how-to-reduce-your-spend.mdx +217 -0
  140. package/docs/idempotency.mdx +504 -0
  141. package/docs/introduction.mdx +223 -0
  142. package/docs/limits.mdx +241 -0
  143. package/docs/logging.mdx +195 -0
  144. package/docs/machines.mdx +952 -0
  145. package/docs/manual-setup.mdx +632 -0
  146. package/docs/mcp-agent-rules.mdx +41 -0
  147. package/docs/mcp-introduction.mdx +385 -0
  148. package/docs/mcp-tools.mdx +273 -0
  149. package/docs/migrating-from-v3.mdx +334 -0
  150. package/docs/observability/dashboards.mdx +102 -0
  151. package/docs/observability/query.mdx +585 -0
  152. package/docs/open-source-contributing.mdx +16 -0
  153. package/docs/open-source-self-hosting.mdx +541 -0
  154. package/docs/private-networking/aws-console-setup.mdx +304 -0
  155. package/docs/private-networking/overview.mdx +144 -0
  156. package/docs/private-networking/troubleshooting.mdx +78 -0
  157. package/docs/queue-concurrency.mdx +354 -0
  158. package/docs/quick-start.mdx +97 -0
  159. package/docs/realtime/auth.mdx +208 -0
  160. package/docs/realtime/backend/overview.mdx +45 -0
  161. package/docs/realtime/backend/streams.mdx +418 -0
  162. package/docs/realtime/backend/subscribe.mdx +225 -0
  163. package/docs/realtime/how-it-works.mdx +94 -0
  164. package/docs/realtime/overview.mdx +63 -0
  165. package/docs/realtime/react-hooks/overview.mdx +73 -0
  166. package/docs/realtime/react-hooks/streams.mdx +449 -0
  167. package/docs/realtime/react-hooks/subscribe.mdx +674 -0
  168. package/docs/realtime/react-hooks/swr.mdx +87 -0
  169. package/docs/realtime/react-hooks/triggering.mdx +194 -0
  170. package/docs/realtime/react-hooks/use-wait-token.mdx +34 -0
  171. package/docs/realtime/run-object.mdx +174 -0
  172. package/docs/replaying.mdx +72 -0
  173. package/docs/request-feature.mdx +6 -0
  174. package/docs/roadmap.mdx +6 -0
  175. package/docs/run-tests.mdx +20 -0
  176. package/docs/run-usage.mdx +113 -0
  177. package/docs/runs/heartbeats.mdx +38 -0
  178. package/docs/runs/max-duration.mdx +139 -0
  179. package/docs/runs/metadata.mdx +734 -0
  180. package/docs/runs/priority.mdx +31 -0
  181. package/docs/runs.mdx +396 -0
  182. package/docs/self-hosting/docker.mdx +458 -0
  183. package/docs/self-hosting/env/supervisor.mdx +74 -0
  184. package/docs/self-hosting/env/webapp.mdx +276 -0
  185. package/docs/self-hosting/kubernetes.mdx +601 -0
  186. package/docs/self-hosting/overview.mdx +108 -0
  187. package/docs/skills.mdx +85 -0
  188. package/docs/tags.mdx +120 -0
  189. package/docs/tasks/overview.mdx +697 -0
  190. package/docs/tasks/scheduled.mdx +382 -0
  191. package/docs/tasks/schemaTask.mdx +413 -0
  192. package/docs/tasks/streams.mdx +884 -0
  193. package/docs/triggering.mdx +1320 -0
  194. package/docs/troubleshooting-alerts.mdx +385 -0
  195. package/docs/troubleshooting-debugging-in-vscode.mdx +8 -0
  196. package/docs/troubleshooting-github-issues.mdx +6 -0
  197. package/docs/troubleshooting-uptime-status.mdx +6 -0
  198. package/docs/troubleshooting.mdx +398 -0
  199. package/docs/upgrading-packages.mdx +80 -0
  200. package/docs/vercel-integration.mdx +207 -0
  201. package/docs/versioning.mdx +56 -0
  202. package/docs/video-walkthrough.mdx +23 -0
  203. package/docs/wait-for-token.mdx +540 -0
  204. package/docs/wait-for.mdx +42 -0
  205. package/docs/wait-until.mdx +53 -0
  206. package/docs/wait.mdx +18 -0
  207. package/docs/writing-tasks-introduction.mdx +33 -0
  208. package/package.json +10 -6
  209. package/skills/trigger-authoring-chat-agent/SKILL.md +296 -0
  210. package/skills/trigger-authoring-tasks/SKILL.md +254 -0
  211. package/skills/trigger-chat-agent-advanced/SKILL.md +368 -0
  212. package/skills/trigger-cost-savings/SKILL.md +116 -0
  213. package/skills/trigger-realtime-and-frontend/SKILL.md +276 -0
@@ -0,0 +1,398 @@
1
+ ---
2
+ title: "Common problems"
3
+ description: "Some common problems you might experience and their solutions"
4
+ ---
5
+
6
+ import NextjsTroubleshootingMissingApiKey from "/snippets/nextjs-missing-api-key.mdx";
7
+ import NextjsTroubleshootingButtonSyntax from "/snippets/nextjs-button-syntax.mdx";
8
+ import RateLimitHitUseBatchTrigger from "/snippets/rate-limit-hit-use-batchtrigger.mdx";
9
+ import CorepackError from "/snippets/corepack-error.mdx";
10
+
11
+ ## Development
12
+
13
+ ### `EACCES: permission denied`
14
+
15
+ If you see this error:
16
+
17
+ ```
18
+ 6090 verbose stack Error: EACCES: permission denied, rename '/Users/user/.npm/_cacache/tmp/f1bfea11' -> '/Users/user/.npm/_cacache/content-v2/sha512/31/d8/e094a47a0105d06fd246892ed1736c02eae323726ec6a3f34734eeb71308895dfba4f4f82a88ffe7e480c90b388c91fc3d9f851ba7b96db4dc33fbc65528'
19
+ ```
20
+
21
+ First, clear the npm cache:
22
+
23
+ ```sh
24
+ npm cache clean --force
25
+ ```
26
+
27
+ Then change the permissions of the npm folder (if 1 doesn't work):
28
+
29
+ ```sh
30
+ sudo chown -R $(whoami) ~/.npm
31
+ ```
32
+
33
+ ### Clear the build cache
34
+
35
+ 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.
36
+
37
+ ### Yarn Plug'n'Play conflicts
38
+
39
+ If you see errors like this when running `trigger.dev dev`:
40
+
41
+ ```
42
+ Could not resolve "@trigger.dev/core"
43
+ The Yarn Plug'n'Play manifest forbids importing "@trigger.dev/core" here because it's not listed as a dependency of this package
44
+ ```
45
+
46
+ And you're using Yarn v1.22 or another package manager, check if you have a `.pnp.cjs` file in your home directory. This can happen if you previously had Yarn Plug'n'Play enabled globally. Remove the `.pnp.cjs` file to resolve the issue.
47
+
48
+ ### `Connection error` when logging in
49
+
50
+ If you see "Connection error" when running `trigger login` (or "Failed to create authorization code"), try these in order:
51
+
52
+ 1. **Clear saved auth and retry:** `npx trigger.dev@latest logout`, then `npx trigger.dev@latest login` again. Sometimes an invalid config is cached.
53
+ 2. **VPN or firewall:** Disconnect from VPN or check firewall/proxy; try `npx trigger.dev@latest login --log-level debug` for more detail.
54
+ 3. **TLS / certificate store:** Node may use a different CA store than your OS (e.g. `curl` works but the CLI fails). Try `export NODE_EXTRA_CA_CERTS=/etc/ssl/cert.pem` (macOS/Linux) then login again, or reinstall Node so it gets updated certs. Behind a corporate proxy or custom CA? Set `NODE_EXTRA_CA_CERTS` to that CA file.
55
+
56
+ ### Runs never dequeue in dev
57
+
58
+ If runs sit in the queue and never start while running `trigger.dev dev`, check whether you have more than one local instance running against the same project. Each project has a single dev environment, and only one `trigger.dev dev` instance can consume from it at a time, so a second instance causes runs to be split between them and some appear stuck. Keep a single `trigger.dev dev` running per project. [Upvote isolated dev sessions](https://triggerdev.featurebase.app/p/isolated-dev-sessions-for-multiple-local-trigger-dev-instances) if you need to run multiple local instances.
59
+
60
+ ## Deployment
61
+
62
+ Running the [trigger.dev deploy] command builds and deploys your code. Sometimes there can be issues building your code.
63
+
64
+ You can run the deploy command with `--log-level debug` at the end. This will spit out a lot of information about the deploy. If you can't figure out the problem from the information below please join [our Discord](https://trigger.dev/discord) and create a help forum post. Do NOT share the extended debug logs publicly as they might reveal private information about your project.
65
+
66
+ You can also review the build by supplying the `--dry-run` flag. This will build your project but not deploy it. You can then inspect the build output on your machine.
67
+
68
+ Here are some common problems and their solutions:
69
+
70
+ ### `Failed to build project image: Error building image`
71
+
72
+ There should be a link below the error message to the full build logs on your machine. Take a look at these to see what went wrong. Join [our Discord](https://trigger.dev/discord) and you share it privately with us if you can't figure out what's going wrong. Do NOT share these publicly as the verbose logs might reveal private information about your project.
73
+
74
+ ### `Error: failed to solve: failed to resolve source metadata for docker.io/docker/dockerfile:1`
75
+
76
+ If you see this error after uninstalling Docker Desktop:
77
+
78
+ ```
79
+ Error: failed to solve: failed to resolve source metadata for docker.io/docker/dockerfile:1: error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH
80
+ ```
81
+
82
+ This happens because Docker Desktop left behind a config file that's still trying to use its credential store. To fix this, remove or update the `~/.docker/config.json` file. You don't need Docker Desktop installed to use Trigger.dev.
83
+
84
+ ### `Deployment encountered an error`
85
+
86
+ Usually there will be some useful guidance below this message. If you can't figure out what's going wrong then join [our Discord](https://trigger.dev/discord) and create a Help forum post with a link to your deployment.
87
+
88
+ ### `resource_exhausted`
89
+
90
+ If you see a `resource_exhausted` error during deploy, the build may have hit resource limits on our build infrastructure. Try our [native builder](https://trigger.dev/changelog/deployments-with-native-builds).
91
+
92
+ ### `No loader is configured for ".node" files`
93
+
94
+ This happens because `.node` files are native code and can't be bundled like other packages. To fix this, add your package to [`build.external`](/config/config-file#external) in the `trigger.config.ts` file like this:
95
+
96
+ ```ts trigger.config.ts
97
+ import { defineConfig } from "@trigger.dev/sdk";
98
+
99
+ export default defineConfig({
100
+ project: "<project ref>",
101
+ // Your other config settings...
102
+ build: {
103
+ external: ["your-node-package"],
104
+ },
105
+ });
106
+ ```
107
+
108
+ ### `Cannot find module '/app/lib/worker.js"` when using pino
109
+
110
+ 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).
111
+
112
+ ### `Failed to index deployment` with `Column must be greater than or equal to 0, got -1`
113
+
114
+ This can occur when using `runtime: "bun"` during the indexing phase (we load and execute your task files to discover exports). A short-term workaround is to [pnpm patch](https://pnpm.io/cli/patch) the `source-map` package. See [this GitHub issue](https://github.com/triggerdotdev/trigger.dev/issues/3045) for the patch details.
115
+
116
+ ### `reactDOMServer.renderToPipeableStream is not a function` when using react-email
117
+
118
+ If you see this error when using `@react-email/render`:
119
+
120
+ ```
121
+ TypeError: reactDOMServer.renderToPipeableStream is not a function
122
+ at __spreadValues.selectors (file:///node_modules/.pnpm/@react-email+render@1.0.6_react-dom@19.0.0_react@19.0.0/node_modules/@react-email/render/dist/node/index.mjs:162:37)
123
+ ```
124
+
125
+ This happens because react-email packages have bundling conflicts with our build process. To fix this, add the react-email packages to your `external` build settings in your `trigger.config.ts` file:
126
+
127
+ ```ts trigger.config.ts
128
+ import { defineConfig } from "@trigger.dev/sdk";
129
+
130
+ export default defineConfig({
131
+ project: "<project ref>",
132
+ // Your other config settings...
133
+ build: {
134
+ external: ["react", "react-dom", "@react-email/render", "@react-email/components"],
135
+ },
136
+ });
137
+ ```
138
+
139
+ <CorepackError />
140
+
141
+ ## Project setup issues
142
+
143
+ ### `The requested module 'node:events' does not provide an export named 'addAbortListener'`
144
+
145
+ If you see this error it means you're not a supported version of Node:
146
+
147
+ ```
148
+ SyntaxError: The requested module 'node:events' does not provide an export named 'addAbortListener'
149
+ at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
150
+ at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
151
+
152
+ Node.js v19.9.0
153
+ ```
154
+
155
+ You need to be on at least these minor versions:
156
+
157
+ | Version | Minimum |
158
+ | ------- | ------- |
159
+ | 18 | 18.20+ |
160
+ | 20 | 20.5+ |
161
+ | 21 | 21.0+ |
162
+ | 22 | 22.0+ |
163
+
164
+ ## Runtime issues
165
+
166
+ ### `Environment variable not found:`
167
+
168
+ Your code is deployed separately from the rest of your app(s) so you need to make sure that you set any environment variables you use in your tasks in the Trigger.dev dashboard. [Read the guide](/deploy-environment-variables).
169
+
170
+ ### `Error: @prisma/client did not initialize yet.`
171
+
172
+ Prisma uses code generation to create the client from your schema file. This means you need to add a bit of config so we can generate this file before your tasks run: [Read the guide](/config/extensions/prismaExtension).
173
+
174
+ ### Database connection requires IPv4
175
+
176
+ Trigger.dev currently only supports IPv4 database connections. If your database provider only provides an IPv6 connection string, you'll need to use an IPv4 address instead. [Upvote IPv6 support](https://triggerdev.featurebase.app/p/support-ipv6-database-connections).
177
+
178
+ ### `Parallel waits are not supported`
179
+
180
+ In the current version, you can't perform more that one "wait" in parallel.
181
+
182
+ Waits include:
183
+
184
+ - `wait.for()`
185
+ - `wait.until()`
186
+ - `task.triggerAndWait()`
187
+ - `task.batchTriggerAndWait()`
188
+ - `retry.onThrow()`
189
+ - And any of our functions with `wait` in the name.
190
+
191
+ This restriction exists because we suspend the task server after a wait, and resume it when the wait is done. At the moment, if you do more than one wait, the run will never continue when deployed, so we throw this error instead.
192
+
193
+ The most common situation this happens is if you're using `Promise.all` around some of our wait functions. Instead of doing this use our built-in functions for [triggering tasks](/triggering#triggering-from-inside-another-task). We have functions that allow you to trigger different tasks in parallel.
194
+
195
+ ### When triggering subtasks the parent task finishes too soon
196
+
197
+ 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.
198
+
199
+ ### `COULD_NOT_FIND_EXECUTOR`
200
+
201
+ If you see a `COULD_NOT_FIND_EXECUTOR` error when triggering a task, it may be caused by dynamically importing the child task. When tasks are dynamically imported, the executor may not be properly registered.
202
+
203
+ Use a top-level import instead:
204
+
205
+ ```ts
206
+ import { myChildTask } from "~/trigger/my-child-task";
207
+
208
+ export const myTask = task({
209
+ id: "my-task",
210
+ run: async (payload: string) => {
211
+ await myChildTask.trigger({ payload: "data" });
212
+ },
213
+ });
214
+ ```
215
+
216
+ Alternatively, use `tasks.trigger()` or `batch.triggerAndWait()` without importing the task:
217
+
218
+ ```ts
219
+ import { batch } from "@trigger.dev/sdk";
220
+
221
+ export const myTask = task({
222
+ id: "my-task",
223
+ run: async (payload: string) => {
224
+ await batch.triggerAndWait([{ id: "my-child-task", payload: "data" }]);
225
+ },
226
+ });
227
+ ```
228
+
229
+ ### Rate limit exceeded
230
+
231
+ <RateLimitHitUseBatchTrigger />
232
+
233
+ View the [rate limits](/limits) page for more information.
234
+
235
+ ### Runs waiting in queue due to concurrency limits
236
+
237
+ If runs are staying in the `QUEUED` state for extended periods, check your concurrency usage in the dashboard. Review how many runs are `EXECUTING` or `DEQUEUED` (these count against limits) and check if any runs are stuck in `EXECUTING` state, as they may be blocking new runs.
238
+
239
+ **Solutions:**
240
+
241
+ - **Increase concurrency limits** - If you're on a paid plan, increase your environment concurrency limit via the dashboard
242
+ - **Review queue concurrency limits** - Check if individual queues have restrictive `concurrencyLimit` settings
243
+ - **Check for stuck runs** - See if stalled runs are blocking new executions
244
+
245
+ ### `Crypto is not defined`
246
+
247
+ This can happen in different situations, for example when using plain strings as idempotency keys. Support for `Crypto` without a special flag was added in Node `v19.0.0`. You will have to upgrade Node - we recommend even-numbered major releases, e.g. `v20` or `v22`. Alternatively, you can switch from plain strings to the `idempotencyKeys.create` SDK function. [Read the guide](/idempotency).
248
+
249
+ ### Task run stalled executing
250
+
251
+ If you see a `TASK_RUN_STALLED_EXECUTING` error it means that we didn't receive a heartbeat from your task before the stall timeout. We automatically heartbeat runs every 30 seconds, and the heartbeat timeout is 5 minutes.
252
+
253
+ <Note>
254
+
255
+ If this was a dev run, then most likely the `trigger.dev dev` CLI was stopped, and it wasn't an issue with your code.
256
+
257
+ </Note>
258
+
259
+ These errors can happen when code inside your task is blocking the event loop for too long. The most likely cause would be an accidental infinite loop. It could also be a CPU-heavy operation that's blocking the event loop, like nested loops with very large arrays.
260
+
261
+ If you use **Prisma 7.x**, query compilation and caching run on the main thread and can block the event loop during heavy or repeated database work. In tasks that do a lot of Prisma calls (e.g. in loops or many sequential queries), add `await heartbeats.yield()` periodically so the event loop can run and send heartbeats.
262
+
263
+ We recommend reading the [Don't Block the Event Loop](https://nodejs.org/en/learn/asynchronous-work/dont-block-the-event-loop) guide from Node.js for common patterns that can cause this.
264
+
265
+ If you are doing a continuous CPU-heavy task, then we recommend you try using our `heartbeats.yield` function to automatically yield to the event loop periodically:
266
+
267
+ ```ts
268
+ import { heartbeats } from "@trigger.dev/sdk";
269
+
270
+ // code inside your task
271
+ for (const row of bigDataset) {
272
+ await heartbeats.yield(); // safe to call every iteration, we will only actually yield when we need to
273
+ process(row); // this is a synchronous operation
274
+ }
275
+ ```
276
+
277
+ <Note>
278
+
279
+ You could also offload the CPU-heavy work to a Node.js worker thread, but this is more complex to setup currently. We are planning on adding support for this in the future.
280
+
281
+ </Note>
282
+
283
+ If the above doesn't work, then we recommend you try increasing the machine size of your task. See our [machines guide](/machines) for more information.
284
+
285
+ ### Uncaught exceptions
286
+
287
+ If you see a `TASK_RUN_UNCAUGHT_EXCEPTION` error, an exception escaped your task's `run()` function without being thrown through your `await` chain — the runtime caught it via Node's `process.on("uncaughtException")` handler. The dashboard surfaces this as a regular task failure (status `Failed`) and the run will retry according to your task's retry policy, but the exception still indicates a bug worth fixing.
288
+
289
+ The most common cause is a Node `EventEmitter` emitting an `"error"` event with no listener attached. When this happens, Node escalates the event into an `uncaughtException`. Long-lived clients like `node-redis`, `pg`, `kafkajs`, and `mongodb` all surface socket-level errors this way.
290
+
291
+ For example, a `node-redis` client with no error listener will fail your run with an `Error: read ECONNRESET` (or similar TCP error) the next time the socket is reset:
292
+
293
+ ```ts
294
+ import { task } from "@trigger.dev/sdk";
295
+ import { createClient } from "redis";
296
+
297
+ export const myTask = task({
298
+ id: "my-task",
299
+ run: async () => {
300
+ const client = createClient({ url: process.env.REDIS_URL });
301
+
302
+ // BAD: no .on("error", ...) listener — a socket reset will crash the run
303
+ // with an uncaught exception, even if the next .get() would have worked.
304
+ await client.connect();
305
+ return await client.get("foo");
306
+ },
307
+ });
308
+ ```
309
+
310
+ Fix it by attaching an `error` listener so the event has somewhere to go:
311
+
312
+ ```ts
313
+ const client = createClient({ url: process.env.REDIS_URL });
314
+
315
+ // GOOD: the listener catches socket-level errors. The awaited command
316
+ // (e.g. .get) will still reject if the connection is broken, and that
317
+ // rejection propagates through your run() and fails the attempt cleanly.
318
+ client.on("error", (err) => {
319
+ logger.warn("Redis client error", { err });
320
+ });
321
+
322
+ await client.connect();
323
+ return await client.get("foo");
324
+ ```
325
+
326
+ The same fix applies to any library that emits `"error"` events. As a rule, attach an `.on("error", ...)` listener to every long-lived client you create inside a task.
327
+
328
+ <Note>
329
+
330
+ Unhandled promise rejections (e.g. `Promise.reject(...)` with no `.catch`) take the same path — Node routes them through `uncaughtException` by default, and the runtime treats them as `TASK_RUN_UNCAUGHT_EXCEPTION` for the same reasons. Make sure every promise either gets `await`ed or has a `.catch(...)` handler.
331
+
332
+ </Note>
333
+
334
+ ### Realtime stream error (`sendBatchNonBlocking` / `S2AppendSession`)
335
+
336
+ Errors mentioning `sendBatchNonBlocking`, `@s2-dev/streamstore`, or `S2AppendSession` (often with `code: undefined`) can occur when you close a stream and then await `waitUntilComplete()`, or when a stream runs for a long time (e.g. 20+ minutes). Wrap `waitUntilComplete()` in try/catch so Transport/closed-stream errors don't fail your task:
337
+
338
+ ```ts
339
+ import { streams } from "@trigger.dev/sdk";
340
+
341
+ const { waitUntilComplete } = streams.pipe("my-stream", dataStream); // or streams.writer(...)
342
+ try {
343
+ await waitUntilComplete();
344
+ } catch (err) {
345
+ // Transport/closed-stream; log if needed or ignore
346
+ }
347
+ ```
348
+
349
+ Alternatively, await `waitUntilComplete()` before closing the stream. See [Realtime Streams](/tasks/streams) for more.
350
+
351
+ ## Framework specific issues
352
+
353
+ ### NestJS swallows all errors/exceptions
354
+
355
+ If you're using NestJS and you add code like this into your tasks you will prevent any errors from being surfaced:
356
+
357
+ ```ts
358
+ export const simplestTask = task({
359
+ id: "nestjs-example",
360
+ run: async (payload) => {
361
+ //by doing this you're swallowing any errors
362
+ const app = await NestFactory.createApplicationContext(AppModule);
363
+ await app.init();
364
+
365
+ //etc...
366
+ },
367
+ });
368
+ ```
369
+
370
+ 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.
371
+
372
+ ### React is not defined
373
+
374
+ If you see this error:
375
+
376
+ ```
377
+ Worker failed to start ReferenceError: React is not defined
378
+ ```
379
+
380
+ Either add this to your file:
381
+
382
+ ```ts
383
+ import React from "react";
384
+ ```
385
+
386
+ Or change the tsconfig jsx setting:
387
+
388
+ ```json
389
+ {
390
+ "compilerOptions": {
391
+ //...
392
+ "jsx": "react-jsx"
393
+ }
394
+ }
395
+ ```
396
+
397
+ <NextjsTroubleshootingMissingApiKey />
398
+ <NextjsTroubleshootingButtonSyntax />
@@ -0,0 +1,80 @@
1
+ ---
2
+ title: "How to upgrade the Trigger.dev packages"
3
+ sidebarTitle: "Upgrading packages"
4
+ description: "When we release fixes and new features we recommend you upgrade your Trigger.dev packages."
5
+ ---
6
+
7
+ ## Update command
8
+
9
+ Run this command in your project:
10
+
11
+ ```sh
12
+ npx trigger.dev@latest update
13
+ ```
14
+
15
+ This will update all of the Trigger.dev packages in your project to the latest version.
16
+
17
+ ## Running the CLI locally
18
+
19
+ When you run the CLI locally use the latest version for the `dev` and `deploy` commands:
20
+
21
+ ```sh
22
+ npx trigger.dev@latest dev
23
+ ```
24
+
25
+ ```sh
26
+ npx trigger.dev@latest deploy
27
+ ```
28
+
29
+ These commands will also give you the option to upgrade if you are behind on versions.
30
+
31
+ ## Deploying with GitHub Actions
32
+
33
+ You can deploy using [GitHub Actions](/github-actions). We recommend that you lock your version in the workflow file so make sure to upgrade.
34
+
35
+ <Warning>
36
+ The deploy step will fail if version mismatches are detected. It's important that you update the
37
+ version using the steps below.
38
+ </Warning>
39
+
40
+ <Steps>
41
+ <Step title="Find your workflow file">
42
+ In your `.githubs/workflows` folder you can find your workflow yml files. You may have a prod
43
+ and staging one.
44
+ </Step>
45
+ <Step title="Update the version for the run command">
46
+ In the steps you'll see a `run` command. It will run the trigger.dev deploy CLI command. Make
47
+ sure to update this version to the latest version (e.g. `npx trigger.dev@3.0.0 deploy`).
48
+ </Step>
49
+ </Steps>
50
+
51
+ ## package.json dev dependency
52
+
53
+ Instead of using `npx`, `pnpm dlx` or `yarn dlx` you can add the Trigger.dev CLI as a dev dependency to your package.json file.
54
+
55
+ For example:
56
+
57
+ ```json
58
+ {
59
+ "devDependencies": {
60
+ "trigger.dev": "3.0.0"
61
+ }
62
+ }
63
+ ```
64
+
65
+ If you've done this make sure to update the version to match the `@trigger.dev/sdk` package.
66
+
67
+ Once you have added the `trigger.dev` package to your `devDependencies`, you can use `npm exec trigger.dev`, `pnpm exec trigger.dev`, or `yarn exec trigger.dev` to run the CLI.
68
+
69
+ But we recommend adding your dev and deploy commands to the `scripts` section of your `package.json` file:
70
+
71
+ ```json
72
+ {
73
+ "scripts": {
74
+ "dev:trigger": "trigger dev",
75
+ "deploy:trigger": "trigger deploy"
76
+ }
77
+ }
78
+ ```
79
+
80
+ Then you can run `npm run dev:trigger` and `npm run deploy:trigger` to run the CLI.
@@ -0,0 +1,207 @@
1
+ ---
2
+ title: "Vercel integration"
3
+ description: "Automatically deploy your tasks whenever you deploy to Vercel."
4
+ ---
5
+
6
+ ## How it works
7
+
8
+ The Vercel integration connects your Vercel project to your Trigger.dev project so that every Vercel deployment automatically triggers a Trigger.dev deployment. It also syncs environment variables from Vercel into Trigger.dev and supports atomic deployments to keep your app and tasks in sync.
9
+
10
+ This eliminates the need to manually run the `trigger.dev deploy` command or maintain custom CI/CD workflows for Vercel-based projects.
11
+
12
+ <Note>
13
+ The Vercel integration requires the [GitHub integration](/github-integration) to be connected as
14
+ well, since Trigger.dev builds your tasks from your GitHub repository.
15
+ </Note>
16
+
17
+ ## Installation
18
+
19
+ You can connect Vercel from two entry points:
20
+
21
+ ### From the Trigger.dev dashboard
22
+
23
+ <Steps>
24
+
25
+ <Step title="Connect Vercel">
26
+ Go to your project's **Settings** page and click **Connect Vercel**. This will redirect you to
27
+ Vercel to authorize the Trigger.dev app.
28
+ </Step>
29
+
30
+ <Step title="Select a Vercel project">
31
+ Choose which Vercel project to connect to your Trigger.dev project.
32
+ </Step>
33
+
34
+ <Step title="Map environments">
35
+ If your Vercel project has custom environments, choose which one maps to your Trigger.dev staging
36
+ environment.
37
+ </Step>
38
+
39
+ <Step title="Sync environment variables">
40
+ Review the environment variables that will be pulled from Vercel into Trigger.dev. You can
41
+ deselect any variables you don't want to sync.
42
+ </Step>
43
+
44
+ <Step title="Configure build options">
45
+ Optionally adjust [build options](#build-options) for atomic deployments, env var pulling, and new
46
+ env var discovery.
47
+ </Step>
48
+
49
+ <Step title="Connect GitHub">
50
+ If your GitHub repository isn't already connected, you'll be prompted to connect it.
51
+ </Step>
52
+
53
+ </Steps>
54
+
55
+ ### From the Vercel Marketplace
56
+
57
+ <Steps>
58
+
59
+ <Step title="Install the integration">
60
+ Install the [Trigger.dev integration from the Vercel
61
+ Marketplace](https://vercel.com/marketplace/trigger). This will redirect you to Trigger.dev to
62
+ complete setup.
63
+ </Step>
64
+
65
+ <Step title="Select your Trigger.dev organization and project">
66
+ Choose which Trigger.dev organization and project to connect. If you're new to Trigger.dev, you'll
67
+ be guided through creating an organization and project.
68
+ </Step>
69
+
70
+ <Step title="Connect GitHub">
71
+ If your GitHub repository isn't already connected, you'll be prompted to connect it.
72
+ </Step>
73
+
74
+ </Steps>
75
+
76
+ <Note>
77
+ When installing from the Vercel Marketplace, default Build options are applied automatically. You
78
+ can adjust them later in your project settings.
79
+ </Note>
80
+
81
+ <Warning>
82
+ **Vercel Root Directory:** If your Vercel project uses a **Root Directory** (e.g. you deploy a
83
+ single subfolder such as `app` or `web`), you may see "The specified Root Directory does not
84
+ exist" after connecting the integration. If you see this error, try using the **repository root**
85
+ (leave Root Directory empty) in your Vercel project settings. If your Vercel frontend build
86
+ requires a Root Directory (e.g. in a monorepo), keep that setting in Vercel and instead point
87
+ Trigger.dev to the subfolder by setting the **Trigger config file** path (and other [Build
88
+ options](#build-options)) in your Trigger.dev project configuration. Trigger.dev always builds
89
+ from the repo root.
90
+ </Warning>
91
+
92
+ ## Environment variable sync
93
+
94
+ The integration syncs environment variables in both directions:
95
+
96
+ **Vercel → Trigger.dev**: Environment variables from your Vercel project are pulled into Trigger.dev. This happens during the initial setup and optionally before each build. Variables are synced per-environment (production, staging, preview).
97
+
98
+ **Trigger.dev → Vercel**: Trigger.dev syncs API keys (like `TRIGGER_SECRET_KEY`) to your Vercel project so your app can communicate with Trigger.dev.
99
+
100
+ The following variables are excluded from the Vercel → Trigger.dev sync:
101
+
102
+ - `TRIGGER_SECRET_KEY`, `TRIGGER_VERSION`, `TRIGGER_PREVIEW_BRANCH` (managed by Trigger.dev)
103
+ - Sensitive/secret-type variables (Vercel API limitation)
104
+
105
+ You can control sync behavior per-variable from your project's Vercel settings. Deselecting a variable prevents its value from being updated during future syncs.
106
+
107
+ <Note>
108
+ Environment variables are pulled from Vercel before each build. To sync updated values into
109
+ Trigger.dev, trigger a new Vercel deployment — either by pushing a commit to your connected branch
110
+ or by redeploying from the Vercel dashboard.
111
+ </Note>
112
+
113
+ <Warning>
114
+ If you are experiencing incorrectly populated environment variables, check that you are not using
115
+ the `syncVercelEnvVars` build extension in your `trigger.config.ts`. This extension is deprecated
116
+ and conflicts with the Vercel integration's built-in env var syncing. Remove it if present.
117
+ </Warning>
118
+
119
+ ### Supabase and Neon database branching
120
+
121
+ If you use [Supabase Branching](https://supabase.com/docs/guides/deployment/branching) or [Neon Database Branching](https://neon.tech/docs/guides/branching-intro) for preview environments, disable syncing for database env vars on the Environment Variables page and use the [syncSupabaseEnvVars](/config/extensions/syncEnvVars#syncsupabaseenvvars) or [syncNeonEnvVars](/config/extensions/syncEnvVars#syncneonenvvars) build extensions instead. These extensions automatically resolve the correct branch-specific credentials at build time.
122
+
123
+ ## Atomic deployments
124
+
125
+ Atomic deployments ensure your Vercel app and Trigger.dev tasks are deployed in sync. When enabled, Trigger.dev gates your Vercel deployment until the task build completes, then triggers a Vercel redeployment with the correct `TRIGGER_VERSION` set. This guarantees your app always uses the matching version of your tasks.
126
+
127
+ ```mermaid
128
+ sequenceDiagram
129
+ participant Dev as Developer
130
+ participant GH as GitHub
131
+ participant V as Vercel
132
+ participant TD as Trigger.dev
133
+
134
+ Dev->>GH: Push code
135
+ GH->>V: Webhook: new commit
136
+ V->>V: Start deployment
137
+ V->>TD: Deployment created
138
+ Dev->>GH: Create pull request
139
+ GH->>TD: Pull request created
140
+ TD->>TD: Start task build
141
+
142
+ V->>TD: Deployment check
143
+ TD-->>V: Check pending (gate deployment)
144
+ TD->>TD: Build completes
145
+ TD->>V: Set TRIGGER_VERSION env var
146
+ TD->>V: Trigger redeployment
147
+ V->>V: Redeploy with correct TRIGGER_VERSION
148
+ V->>TD: Deployment check (redeployment)
149
+ TD-->>V: Check passed
150
+ V->>V: Promote deployment
151
+ V->>TD: Deployment promoted
152
+ TD->>TD: Promote build
153
+ ```
154
+
155
+ Atomic deployments are enabled for the production environment by default.
156
+
157
+ <Note>
158
+ When atomic deployments are enabled, the integration automatically disables `Auto-assign Custom
159
+ Production Domains` on your Vercel project. This is required so that Vercel doesn't promote a
160
+ deployment before the Trigger.dev build is ready.
161
+ </Note>
162
+
163
+ Previously, setting up atomic deployments with Vercel required custom GitHub Actions workflows. The Vercel integration automates this entirely. For more details on how atomic deployments work, see [Atomic deploys](/deployment/atomic-deployment).
164
+
165
+ ## Environment mapping
166
+
167
+ The integration maps Vercel environments to Trigger.dev environments:
168
+
169
+ | Vercel environment | Trigger.dev environment |
170
+ | ------------------ | ------------------------------ |
171
+ | Production | Production |
172
+ | Custom environment | Staging (you choose which one) |
173
+ | Preview | Preview |
174
+ | Development | Development |
175
+
176
+ If your Vercel project has a custom environment, you can select which one maps to your Trigger.dev staging environment during setup or in your project settings.
177
+
178
+ <Note>
179
+ Preview deployments require the preview environment to be enabled on your project. Learn more
180
+ about [preview branches](/deployment/preview-branches).
181
+ </Note>
182
+
183
+ ## Build options
184
+
185
+ You can configure the following settings per-environment from your project's Vercel settings:
186
+
187
+ - **Atomic deployments**: Controls whether Trigger.dev and Vercel deployments are synchronized. Enabled for production by default.
188
+ - **Pull env vars before build**: When enabled, Trigger.dev pulls the latest environment variables from Vercel before each build. Enabled for production, staging, and preview by default.
189
+ - **Discover new env vars**: When enabled, new environment variables found in Vercel that don't yet exist in Trigger.dev are created automatically during builds. Only available for environments that also have env var pulling enabled. Enabled for production, staging, and preview by default.
190
+
191
+ To change build options that would normally go in `trigger.config.ts` (such as [extensions](/config/config-file#extensions) or other build configuration), use **Build options** on your project's configuration page in the Trigger.dev dashboard.
192
+
193
+ ## Disconnecting
194
+
195
+ You can disconnect the Vercel integration from either side:
196
+
197
+ - **From Trigger.dev**: Go to your project **Settings** and disconnect Vercel.
198
+ - **From Vercel**: Uninstall the Trigger.dev integration from your Vercel dashboard. This is automatically detected and the connection is removed on the Trigger.dev side.
199
+
200
+ Disconnecting stops automatic deployments, environment variable syncing, and deployment checks. Your existing deployments and environment variables are not affected.
201
+
202
+ ## Related
203
+
204
+ - [GitHub integration](/github-integration)
205
+ - [Atomic deploys](/deployment/atomic-deployment)
206
+ - [Environment variables](/deploy-environment-variables)
207
+ - [Preview branches](/deployment/preview-branches)