Skip to content

fix(deploy): capture migrate stderr so P3005 detection actually works#30

Merged
abdout merged 1 commit into
mainfrom
fix/migrate-stdio-capture
May 10, 2026
Merged

fix(deploy): capture migrate stderr so P3005 detection actually works#30
abdout merged 1 commit into
mainfrom
fix/migrate-stdio-capture

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented May 10, 2026

Fix-fix-up. #29's P3005 catch was bypassed because of an execSync stdio quirk.

What broke

The post-#29 Vercel build still failed with the original P3005 error:

Error: P3005
The database schema is not empty.
❌ prisma migrate deploy failed: Command failed: pnpm exec prisma migrate deploy

The warning I added in #29 (⚠️ P3005: production schema is not baselined) never printed.

Why

execSync with stdio: "inherit" streams the child's stdout/stderr directly to the parent — but does not populate err.stderr / err.stdout on failure. The catch block was checking combined.includes("P3005") against an empty string, so the special-case branch never triggered.

Fix

- stdio: "inherit", encoding: "utf8"
+ stdio: ["inherit", "pipe", "pipe"], encoding: "utf8"

stdin still inherits, but stdout+stderr are captured into err.stdout/err.stderr. The script then echoes them to the build log itself so we keep the same visibility "inherit" gave us.

Both success and failure paths now write captured output explicitly.

🤖 Generated with Claude Code

Previous attempt at P3005 tolerance (#29) used stdio: 'inherit'
on the execSync call. That made the migrate deploy output stream to
the build log but left err.stderr/err.stdout empty on failure — so
the catch block's '${combined}.includes("P3005")' check ran
against an empty string and the special-case never triggered.

Confirmed live in the post-merge Vercel build log (commit 2656756):
the build still failed with the original P3005 error, never hitting
my warning branch.

Switch to stdio: ['inherit', 'pipe', 'pipe'] so:
  - stdin still inherits (interactive prompts can still happen)
  - stdout+stderr are captured into err.stdout/err.stderr on failure
  - we echo them ourselves to keep build logs informative

Both the success and failure paths now write the captured output to
the build log explicitly, preserving the visibility 'inherit' gave us.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mkan Ready Ready Preview, Comment May 10, 2026 6:34am

@abdout abdout merged commit d91c6e8 into main May 10, 2026
8 checks passed
@abdout abdout deleted the fix/migrate-stdio-capture branch May 10, 2026 06:35
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.

1 participant