drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-kit swallows stack traces on schema-load errors, printing only the message
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### What version of `drizzle-orm` are you using?
1.0.0-rc.3
### What version of `drizzle-kit` are you using?
1.0.0-rc.3
### Other packages
_No response_
### Describe the Bug
When a schema file throws during module evaluation, `drizzle-kit generate` prints only the error message and exits. The stack trace is discarded, so there is no indication of which file or line crashed.
Repro: point the config at a schema file that throws while loading.
```ts
// schema.ts
import { pgTable, text } from "drizzle-orm/pg-core";
const broken: { kind: string } | undefined = undefined;
console.log(broken!.kind); // stand-in for any eval-time crash
export const users = pgTable("users", { id: text("id") });
```
```ts
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: "postgresql",
schema: "./schema.ts",
out: "./migrations",
});
```
```
$ drizzle-kit generate
Reading config file 'drizzle.config.ts'
Error Cannot read properties of undefined (reading 'kind')
```
That single line is the entire output. In a real project the schema spans dozens of files, and an eval-time crash (ours came from a circular import that left a table half-initialized) gives you nothing to go on. We ended up patching `bin.cjs` to recover the stack:
```
Error Cannot read properties of undefined (reading 'kind')
TypeError: Cannot read properties of undefined (reading 'kind')
at /path/to/server/schema.ts:5:20
at async Function.import (node_modules/drizzle-kit/bin.cjs:38495:17)
at async prepareFromSchemaFiles$5 (node_modules/drizzle-kit/bin.cjs:89621:35)
...
```
The swallow happens in the CLI's `unknown_error` theme handler (`src/cli/index.ts`), which logs `e.message` and returns. Printing `e.stack` there (or behind a `--verbose` flag) would make schema-loading crashes debuggable.
The same applies to `migrate`, `push`, and any other command that loads schema files.
Contributor guide
Assessment
This issue has not been assessed yet.