Add Unix socket connection support to PostgreSQL session storage#3114
Open
hashem59 wants to merge 1 commit intoShopify:mainfrom
Open
Add Unix socket connection support to PostgreSQL session storage#3114hashem59 wants to merge 1 commit intoShopify:mainfrom
hashem59 wants to merge 1 commit intoShopify:mainfrom
Conversation
146d118 to
769578d
Compare
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
769578d to
f79b36d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Fixes #3113
The PostgreSQL session storage package currently cannot connect via Unix domain sockets because
postgres-connection.tsmanually decomposes the connection URL into individualhost,port,user,password, anddatabasefields — 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 inpackage.jsonbut was never used in the connection code — to parse connection URLs instead of manualURLdecomposition. This is a minimal change that:hostquery parameterVerified locally against real PostgreSQL 15 with:
postgres://user@localhost:5432/db) ✅postgres://user@localhost/db) ✅?host=parameter (postgres://user@/db?host=/tmp) ✅Usage example:
Type of change
Checklist
pnpm changesetto create a draft changelog entry (do NOT update theCHANGELOG.mdfiles manually)