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 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.

Like this:

trigger.config.ts
import type { TriggerConfig } from "@trigger.dev/sdk/v3";

export const config: TriggerConfig = {
  //..other stuff
  //either regex or strings of package names
  dependenciesToBundle: [/@sindresorhus/, "escape-string-regexp"],
};

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 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 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 and create a Help forum post with a link to your deployment.

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.

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.

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.

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:

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.