Skip to content

fix: add turbo start task with passThroughEnv for deployment env injection#993

Open
jingerpie wants to merge 1 commit intoAmanVarshney01:mainfrom
jingerpie:fix/turbo-start-passthrough-env
Open

fix: add turbo start task with passThroughEnv for deployment env injection#993
jingerpie wants to merge 1 commit intoAmanVarshney01:mainfrom
jingerpie:fix/turbo-start-passthrough-env

Conversation

@jingerpie
Copy link
Copy Markdown

@jingerpie jingerpie commented Mar 26, 2026

Summary

  • Adds a start task to the generated turbo.json with passThroughEnv: ["*"]
  • Adds passThroughEnv to the TurboTask interface

Problem

Turborepo filters environment variables by default. When deploying with turbo run start --filter=server on Docker-based platforms (Dokploy, Railway, etc.), all server env vars are undefined at runtime because Turborepo doesn't forward them to the child process.

This causes immediate crashes with @t3-oss/env-core validation:

❌ Invalid environment variables: [
  { path: ["DATABASE_URL"], message: "Invalid input: expected string, received undefined" },
  { path: ["BETTER_AUTH_SECRET"], message: "Invalid input: expected string, received undefined" },
  ...
]

Fix

The start task with passThroughEnv: ["*"] tells Turborepo to forward all environment variables to the server process, which is the expected behavior for production deployments.

Test plan

  • Verify generated turbo.json includes the start task with passThroughEnv
  • Deploy a scaffolded project using turbo run start --filter=server and confirm env vars are available

Fixes #992

Summary by CodeRabbit

Release Notes

  • Chores
    • Enhanced build task configuration to support environment variable forwarding.
    • Added a new start task to the build pipeline with proper dependency management, disabled caching, and persistent execution mode for reliable builds.

…ction

Turborepo filters environment variables by default. Without a start task
with passThroughEnv, running `turbo run start` strips all env vars from
the child process, causing server crashes in Docker-based deployments
(Dokploy, Railway, etc.) where env vars are injected at runtime.

Fixes AmanVarshney01#992
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

@jingerpie is attempting to deploy a commit to the Better T Stack Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9124820a-7fdd-471b-be94-403b0866398f

📥 Commits

Reviewing files that changed from the base of the PR and between 4c715bb and 7aee94f.

📒 Files selected for processing (1)
  • packages/template-generator/src/processors/turbo-generator.ts

Walkthrough

Added an optional passThroughEnv property to the TurboTask interface and introduced a new start task in the base Turbo configuration. The start task depends on build, disables caching, marks as persistent, and forwards all environment variables to the subprocess.

Changes

Cohort / File(s) Summary
Turbo Task Configuration
packages/template-generator/src/processors/turbo-generator.ts
Extended TurboTask interface with optional passThroughEnv?: string[] field. Added new start task definition in getBaseTasks() with dependsOn: ["build"], cache: false, persistent: true, and passThroughEnv: ["*"] to forward environment variables.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a turbo start task with passThroughEnv for deployment environment injection, which is the primary objective.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #992: adds passThroughEnv to TurboTask interface, creates start task with dependsOn, cache, persistent, and passThroughEnv settings.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the objectives: interface extension and start task addition. No extraneous modifications to unrelated code.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turbo start task missing passThroughEnv — server env vars undefined in deployment

1 participant