Skip to content

Clarify pglite-server TCP and Unix socket connection examples#1042

Open
compair-steven wants to merge 2 commits into
electric-sql:mainfrom
compair-steven:compair/clarify-pglite-socket-connections
Open

Clarify pglite-server TCP and Unix socket connection examples#1042
compair-steven wants to merge 2 commits into
electric-sql:mainfrom
compair-steven:compair/clarify-pglite-socket-connections

Conversation

@compair-steven

Copy link
Copy Markdown

Summary

Clarifies the pglite-server connection examples by separating the default TCP listener from Unix socket connections.

The README introduces Unix socket support with --path and shows the generated socket-style DATABASE_URL, but the following psql and Node.js examples use localhost:5432, which applies to the default TCP listener. Since --path takes precedence over host/port, reading those examples sequentially can make it look like localhost:5432 should connect to the Unix socket server.

This keeps both setup paths documented and adds explicit Unix socket examples for psql, node-postgres, and postgres.js.

Validation

  • Ran pnpm -C packages/pglite-socket build
  • Ran pnpm exec prettier --check packages/pglite-socket/README.md
  • Verified locally by starting pglite-server with --path, creating a sentinel table through the generated Unix socket connection string, and checking that the TCP-style localhost:5432 example did not reach that server while the socket-style URL did.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e34b49b45b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/pglite-socket/README.md Outdated
Comment on lines 281 to 284
When using `--run` with `--include-database-url`, you can use the generated `DATABASE_URL`:

```javascript
const sql = postgres(process.env.DATABASE_URL)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't point postgres.js at the socket DATABASE_URL

In the Unix-socket flow, createDatabaseUrl() emits a libpq-style URL like postgresql://postgres:postgres@/postgres?host=/tmp for --path (packages/pglite-socket/src/scripts/server.ts:146), but postgres.js does not use the host query parameter to choose a Unix socket; the repo's own postgres.js socket test uses the path option instead. An app following this example with --path and --include-database-url will try the default TCP host (or hit another server) rather than the PGlite socket, so this should either stay scoped to clients that understand that URL form or show how to pass path to postgres.js.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, and thanks for the prompt review. I just updated this section to avoid suggesting that postgres.js can consume the generated libpq-style Unix socket DATABASE_URL directly. It now keeps the generated URL scoped to clients that understand ?host=/tmp and points postgres.js users back to the path option.

Hopefully this addresses the concern!

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.

1 participant