Skip to content

fix(den-db): support socketPath in DATABASE_URL for Cloud SQL connections#1841

Open
Dwij1704 wants to merge 1 commit into
different-ai:devfrom
Dwij1704:fix/1805-mysql-socketpath
Open

fix(den-db): support socketPath in DATABASE_URL for Cloud SQL connections#1841
Dwij1704 wants to merge 1 commit into
different-ai:devfrom
Dwij1704:fix/1805-mysql-socketpath

Conversation

@Dwij1704
Copy link
Copy Markdown

Summary

  • Parse ?socketPath (and the ?socket alias) from the MySQL DATABASE_URL and pass it through parseMySqlConnectionConfig.
  • When present, mysql2 ignores host/port and connects via the Unix socket — fixing both the den-api runtime and drizzle-kit db:push, since drizzle.config.ts already routes through the same parser.
  • Adds a mysql-config.test.ts covering TCP, socketPath, alias, precedence, empty value, SSL coexistence, and validation cases (10 tests).

Why

On Google Cloud Run with Cloud SQL attached via a Unix socket, the recommended DATABASE_URL is mysql://user:pw@localhost/db?socketPath=/cloudsql/<conn>. The parser was dropping the socketPath query parameter entirely, so mysql2 fell back to TCP on 127.0.0.1:3306, which is not available in Cloud Run, and every request 500'd with ECONNREFUSED. The fix is single-source: because drizzle.config.ts calls the same parseMySqlConnectionConfig, fixing the parser fixes migrations too.

Issue

Scope

  • ee/packages/den-db/src/mysql-config.ts — type + parser
  • ee/packages/den-db/test/mysql-config.test.ts — new bun:test coverage

Out of scope

  • TLS/CA handling for socket connections (Cloud SQL sockets do not need it).
  • Changes to client.ts or drizzle.config.ts — neither needs touching since they both spread the parser's return value.

Testing

Ran

  • bun test ee/packages/den-db/test/mysql-config.test.ts — 10 pass / 0 fail
  • pnpm --filter @openwork-ee/den-db build — ok
  • pnpm test:e2e — exit 0 (no regression)

Result

  • pass

CI status

  • pass:
  • code-related failures:
  • external/env/auth blockers: pnpm typecheck shows a pre-existing failure on dev (apps/app/src/react-app/domains/session/artifacts/artifact-spreadsheet-model.ts cannot find module xlsx) introduced by feat(app): open artifacts in session pane #1836. Unrelated to this change; den-db typechecks clean on its own (pnpm --filter @openwork-ee/den-db build succeeds).

Manual verification

  1. pnpm install
  2. bun test ee/packages/den-db/test/mysql-config.test.ts
  3. pnpm --filter @openwork-ee/den-db build
  4. To verify against a real Cloud SQL socket: set DATABASE_URL=mysql://root:password@localhost/<db>?socketPath=/cloudsql/<project>:<region>:<instance> and run pnpm --filter @openwork-ee/den-db db:push; the migration should succeed instead of failing with ECONNREFUSED 127.0.0.1:3306.

Evidence

Risk

  • Low. New field is optional and additive; absent in the parsed output when the query param is missing, so existing TCP-only DATABASE_URL values are unchanged.

Rollback

  • Revert this commit. No schema or migration changes.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 18, 2026

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

Project Deployment Actions Updated (UTC)
openwork-landing Ready Ready Preview, Comment, Open in v0 May 18, 2026 11:38pm

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 18, 2026

@Dwij1704 is attempting to deploy a commit to the Different AI Team on Vercel.

A member of the Team first needs to authorize it.

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.

Cloud SQL socket connection fails — mysql-config.ts does not support socketPath parameter

1 participant