You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I connect to my database with Postgres.js. When I execute a query through drizzle, and I hit an error in my database (such as a column not found, etc.), I expect a stack trace to let me know which line of my code caused the error. This is an error with drizzle's use of Postgres.js, since the error doesn't happen with node-postgres.
The stack trace that appears contains a stack trace of where the error hit inside the Postgres.js adapter, but it doesn't show where the error occurred in drizzle or in my code:
PostgresError: relation "assistants" does not exist
at ErrorResponse (/Users/hansenq/Documents/CS/lightski/node_modules/postgres/cjs/src/connection.js:790:26)
at handle (/Users/hansenq/Documents/CS/lightski/node_modules/postgres/cjs/src/connection.js:476:6)
at Socket.data (/Users/hansenq/Documents/CS/lightski/node_modules/postgres/cjs/src/connection.js:315:9)
at Socket.emit (node:events:515:28)
at Socket.emit (node:domain:488:12)
at addChunk (node:internal/streams/readable:545:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:495:3)
at Socket.Readable.push (node:internal/streams/readable:375:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
severity_local: 'ERROR',
severity: 'ERROR',
code: '42P01',
position: '187',
file: 'parse_relation.c',
line: '1395',
routine: 'parserOpenTable'
}
This makes it extremely difficult to debug where the error happened, since I have no idea where the error was hit.
Expected behavior
When I switch to node-postgres, I the error is what I expect: a stack trace for my app-level code:
error: relation "assistants" does not exist
at /Users/hansenq/Documents/CS/lightski/node_modules/pg-pool/index.js:45:11
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/hansenq/Documents/CS/lightski/node_modules/src/node-postgres/session.ts:64:19
at async backfillEmbedsFromAssistants (/Users/hansenq/Documents/CS/lightski/packages/database/bin/data-migrations/2024-01-23-backfill-embeds-from-assistants.ts:7:22)
at async main (/Users/hansenq/Documents/CS/lightski/packages/database/bin/data-migrations/2024-01-23-backfill-embeds-from-assistants.ts:33:3) {
length: 110,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: '187',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '1395',
routine: 'parserOpenTable'
}
Environment & setup
No response
The text was updated successfully, but these errors were encountered:
Hi, @Hansenq. It appears that the issue you're encountering is related to the differences in how database drivers, specifically Postgres.js and node-postgres (pg), handle and report errors. Each driver has its own error handling mechanism that can affect the stack trace and the level of detail provided in error messages. So, this is not related to Drizzle ORM.
Ah, makes sense. Is there a way inside drizzle to intercept database adapter errors and print out/add more information?
Otherwise, this is pretty nasty error that makes it much more difficult to debug, and it might be good to recommend node-postgres over postgres.js for drizzle users in the documentation, just because of this error handling.
What version of
drizzle-orm
are you using?0.29.3
What version of
drizzle-kit
are you using?0.20.13
Describe the Bug
I connect to my database with Postgres.js. When I execute a query through drizzle, and I hit an error in my database (such as a column not found, etc.), I expect a stack trace to let me know which line of my code caused the error. This is an error with drizzle's use of Postgres.js, since the error doesn't happen with node-postgres.
The stack trace that appears contains a stack trace of where the error hit inside the Postgres.js adapter, but it doesn't show where the error occurred in drizzle or in my code:
This makes it extremely difficult to debug where the error happened, since I have no idea where the error was hit.
Expected behavior
When I switch to node-postgres, I the error is what I expect: a stack trace for my app-level code:
Environment & setup
No response
The text was updated successfully, but these errors were encountered: