Files
triggerdotdev--trigger.dev/docs/troubleshooting.mdx
T
James Ritchie d6786002b2 Full Next.js guide (#1259)
* 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

* WIP adding more steps to the next.js guide

* WIP next.js

* WIP adding tabbed steps for pages/app router

* References to Infisical links to their homepage so it’s clearer

* WIP updating the nextjs guide

* WIP nextjs guide

* More nextjs guide steps

* More copy

* Added rate limit trouble shooting

* Removed old prisma error title

* Added secret key step

* Added a note for logging in using a specified domain if self hosting

* typo

* App router docs copy

* Deploy copy update

* Added a favicon.png to fix a docs build error

* Removed unused snippet

* Server actions now inside a tab

* Server actions + restructured the triggering section

* Added troubleshooting snippet for react event handlers

* Added a new troubleshooting snippet for ESM

* Updated old replaying image to reflect the new UI

* Removed references to reattempting

* Updated replaying from the run page

* Added a bulk replay section

* Updated the writing tasks intro page

* Removed edge runtime code for now

* Added edge runtime – it seems to just work!

* import type
2024-08-20 14:50:39 +01:00

158 lines
5.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Common problems"
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 WorkerFailedToStartWhenRunningDevCommand from '/snippets/worker-failed-to-start.mdx';
## 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.
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.
Here are some common problems and their solutions:
### `Typecheck failed, aborting deployment`
We typecheck your code before deploying. If the typecheck fails, the deployment is aborted. You should see logs with details about the typecheck failure.
You can skip typechecking, by adding the `--skip-typecheck` flag when calling deploy.
### `Error: Cannot find module 'X'`
This errors occurs if we can't figure out how to automatically import some code. You can fix this by adding it to the `dependenciesToBundle` array in the [trigger.config file](/trigger-config).
<BundlePackages/>
### `Failed to build project image: Error building image`
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.
### `Deployment timed out`
The last stage of deployment is to run it on our servers we register the new versions of your tasks with the dashboard during this step. We allow 3 mins for this to succeed or fail. If it fails then you'll see this error.
The first thing to do is to try again. If that fails then join [our Discord](https://trigger.dev/discord) and create a Help forum post with a link to your deployment.
### `Deployment encountered an error`
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.
## Project setup issues
### `The requested module 'node:events' does not provide an export named 'addAbortListener'`
If you see this error it means you're not a supported version of Node:
```
SyntaxError: The requested module 'node:events' does not provide an export named 'addAbortListener'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
Node.js v19.9.0
```
You need to be on at least these minor versions:
| Version | Minimum |
| ----- | ------- |
| 18 | 18.16+ |
| 20 | 20.11+ |
| 21 | 21.0+ |
## Runtime issues
### `Environment variable not found:`
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).
### `Error: @prisma/client did not initialize yet.`
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](/trigger-config#prisma-and-other-generators).
### When triggering subtasks the parent task finishes too soon
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.
### Rate limit exceeded
<RateLimitHitUseBatchTrigger/>
View the [rate limits](/limits) page for more information.
## Framework specific issues
### NestJS swallows all errors/exceptions
If you're using NestJS and you add code like this into your tasks you will prevent any errors from being surfaced:
```ts
export const simplestTask = task({
id: "nestjs-example",
run: async (payload) => {
//by doing this you're swallowing any errors
const app = await NestFactory.createApplicationContext(AppModule);
await app.init();
//etc...
},
});
```
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"
},
}
```
<NextjsTroubleshootingMissingApiKey/>
<NextjsTroubleshootingButtonSyntax/>
<WorkerFailedToStartWhenRunningDevCommand/>