Skip to content

fix(jobs): no Trigger.dev dev-vs-prod env consistency check — dev key in prod deployment fires jobs silently in wrong project #194

Description

@walidboulanouar

Problem

packages/jobs/trigger.config.ts validates TRIGGER_PROJECT_REF exists but never cross-checks that TRIGGER_SECRET_KEY belongs to the same deployment environment:

There is no assertion that a production deployment uses a tr_prod_* key (vs a tr_dev_* key). If a prod deployment accidentally uses a dev Trigger key:

  • Jobs queue in the dev Trigger project
  • Production events silently go unprocessed
  • No error or alert fires

Fix

Add a startup assertion in trigger.config.ts:

const isProd = process.env.NODE_ENV === 'production';
const key = process.env.TRIGGER_SECRET_KEY ?? '';
if (isProd && !key.startsWith('tr_prod_')) {
  throw new Error('Production deployment must use a tr_prod_* Trigger.dev key');
}

Severity

MEDIUM — misconfigured env causes silent job loss in production deployments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions