Skip to content

Add Unix socket connection support to PostgreSQL session storage#3114

Open
hashem59 wants to merge 1 commit intoShopify:mainfrom
hashem59:feature/unix-socket-support
Open

Add Unix socket connection support to PostgreSQL session storage#3114
hashem59 wants to merge 1 commit intoShopify:mainfrom
hashem59:feature/unix-socket-support

Conversation

@hashem59
Copy link
Copy Markdown

@hashem59 hashem59 commented Mar 28, 2026

WHY are these changes introduced?

Fixes #3113

The PostgreSQL session storage package currently cannot connect via Unix domain sockets because postgres-connection.ts manually decomposes the connection URL into individual host, port, user, password, and database fields — dropping all query parameters in the process. This means the standard PostgreSQL ?host=/cloudsql/... query parameter (used for Unix socket paths) is silently ignored.

This is a blocker for users deploying on Google Cloud (Cloud Run, App Engine, GKE) where the Cloud SQL Auth Proxy provides connections exclusively through Unix sockets at paths like /cloudsql/project:region:instance.

This is also the root cause behind #2835 and #493 (SSL parameters dropped), and has led multiple users to fork the package to work around the limitation.

WHAT is this pull request doing?

Uses pg-connection-string — which is already a declared dependency in package.json but was never used in the connection code — to parse connection URLs instead of manual URL decomposition. This is a minimal change that:

Verified locally against real PostgreSQL 15 with:

  • TCP connection with port (postgres://user@localhost:5432/db) ✅
  • TCP connection without port (postgres://user@localhost/db) ✅
  • Unix socket via ?host= parameter (postgres://user@/db?host=/tmp) ✅
  • Special characters in credentials and database names ✅

Usage example:

const shopify = shopifyApp({
  sessionStorage: new PostgreSQLSessionStorage(
    'postgres://username:password@/database?host=/cloudsql/my-project:us-central1:my-instance',
  ),
});

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have used pnpm changeset to create a draft changelog entry (do NOT update the CHANGELOG.md files manually)
  • I have added/updated tests for this change
  • I have documented new APIs/updated the documentation for modified APIs (for public APIs)

@hashem59 hashem59 force-pushed the feature/unix-socket-support branch 2 times, most recently from 146d118 to 769578d Compare March 28, 2026 11:48
Use pg-connection-string (already a declared dependency) to parse
connection URLs instead of manual URL decomposition. This preserves
all connection parameters including the host query parameter used
for Unix domain sockets (e.g. Google Cloud SQL Auth Proxy) and SSL
parameters.

Fixes Shopify#3113
@hashem59 hashem59 force-pushed the feature/unix-socket-support branch from 769578d to f79b36d Compare March 28, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant