[BUG]: drizzle-kit push swallows every execution error and exits 0, silently skipping the remaining statements
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- nodejs, postgresql, typescript
Research direction
Start in src/cli/commands/push.ts at pgPush and inspect its statement-execution try/catch, comparing it with sqlitePush and libSQLPush. Reproduce the behavior with npx drizzle-kit push --force and verify that a failed statement produces a non-zero exit status instead of silently skipping later statements and reporting success.
Written by the indexing model from the issue text.
Description
What version of drizzle-orm are you using?
0.45.2
What version of drizzle-kit are you using?
0.31.10
Describe the Bug
drizzle-kit push wraps its entire statement-execution loop in a catch that only logs, so a failed push prints an error and then exits 0, and every statement after the failing one is never attempted.
src/cli/commands/push.ts, pgPush (0.31.10, bin.cjs around the pgPush = async (...) definition):
try {
if (statements.sqlStatements.length === 0) {
render(`[i] No changes detected`)
} else {
// …pgSuggestions, prompts…
for (const dStmnt of statementsToExecute) {
await db.query(dStmnt) // <-- throws here
}
render(`[✓] Changes applied`)
}
} catch (e) {
console.error(e) // <-- logged, then the function returns normally
}
There is no re-throw and no process.exit(1), so the CLI's exit status is 0.
Two consequences, and the second is the damaging one:
- The exit status is not consultable.
drizzle-kit push && next-thingrunsnext-thingafter a push that applied nothing. Any CI step,package.jsonchain, or script that gates on push's status is gated on a value that is always 0. - Partial application is reported as success.
statementsToExecuteis executed in order inside thetry. When statement N throws, statements N+1 … are skipped — silently. In our case the failing statement sorts before theCREATE CHECK CONSTRAINTgroup, so five CHECK constraints we had just added to the schema were never applied to the database, while the command reported success and the chain continued.
The same catch is not present in sqlitePush / libSQLPush in the same file, so this looks like an oversight rather than a deliberate policy.
Expected behavior
drizzle-kit push exits non-zero when any statement fails, so push && … is a real gate.
If aborting on the first failure is not wanted, the alternative that still fixes the reporting is to run the remaining statements, collect the failures, print them, and exit non-zero — what must not happen is "some statements did not run" being reported with the same exit status as "everything applied".
Environment & setup
Node 26.4.0, PGlite 0.5.4 (driver: "pglite"), macOS/Linux. The statement that fails in our case is a separate defect (composite-PK churn emitting a two-command statement) filed separately — but any failing statement reproduces this one:
// drizzle.config.ts
export default defineConfig({
dialect: "postgresql",
driver: "pglite",
schema: "./schema.ts",
dbCredentials: { url: ".data/pglite" },
})
$ npx drizzle-kit push --force; echo "exit=$?"
[✓] Pulling schema from database...
error: cannot insert multiple commands into a prepared statement
…
exit=0
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from drizzle-team/drizzle-orm
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
drizzle-team/drizzle-orm#6287 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
drizzle-team/drizzle-orm#6229 ·
-
bug drizzle/kit
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
drizzle-team/drizzle-orm#6214 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
drizzle-team/drizzle-orm#6162 · 3 comments · 1 reaction ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
drizzle-team/drizzle-orm#6132 · 2 comments ·
All issues in drizzle-team/drizzle-orm
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100