© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
6 replies
barry

drizzle + postgres + express + ts, errors

https://gist.github.com/barrybtw/67c379371c3f52a61758c94474e8ebf8

In regards to the route
auth_router.post("/signup", () => ...)
auth_router.post("/signup", () => ...)
, I get this error

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:393:5)
    at ServerResponse.setHeader (node:_http_outgoing:644:11)
    at ServerResponse.header (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10)
    at ServerResponse.location (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15)
    at ServerResponse.redirect (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18)
    at file:///Users/nicolaichristensen/Dev/js_world/express-caddy/src/routes/auth.mts:78:19
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_HTTP_HEADERS_SENT'
}
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:393:5)
    at ServerResponse.setHeader (node:_http_outgoing:644:11)
    at ServerResponse.header (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:794:10)
    at ServerResponse.location (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:915:15)
    at ServerResponse.redirect (/Users/nicolaichristensen/Dev/js_world/express-caddy/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/response.js:953:18)
    at file:///Users/nicolaichristensen/Dev/js_world/express-caddy/src/routes/auth.mts:78:19
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_HTTP_HEADERS_SENT'
}


I don't seem to be breaking that so a bit confused?

And if I use a username that's already taken (username has the unique constraint) I get this error
PostgresError: duplicate key value violates unique constraint "user_username_unique"
PostgresError: duplicate key value violates unique constraint "user_username_unique"
, and I can't import the type PostgresError as it's not exported but it's part of the types in the node modules, yet I can't import it without runtime errors. What's the standard for handling sql errors like this?

SyntaxError: The requested module 'postgres' does not provide an export named 'PostgresError'
SyntaxError: The requested module 'postgres' does not provide an export named 'PostgresError'
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle postgres migration gives lots of type errors
Drizzle TeamDTDrizzle Team / help
2y ago
Drizzle-zod errors
Drizzle TeamDTDrizzle Team / help
2y ago
Postgres Schema (namespace) + Drizzle
Drizzle TeamDTDrizzle Team / help
2y ago