pglite-server -m multiplexer: "invalid frontend message type" with a Postgres-wire client in WebContainers

Aperta
#1,039 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
node.js, postgres, typescript

Direzione di ricerca

Inizia con la CLI pglite-server in modalità multiplexer e riproduci la migrazione fornita con un singolo client in WebContainers, quindi confronta il suo wire framing con quello di Node nativo. Traccia la gestione dei messaggi del frontend nei percorsi multiplexer e pglite-socket; il lavoro è completato quando la stessa connessione pg.Client e la migrazione select 1 funzionano in WebContainers senza l’errore «invalid message».

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Running the pglite-server CLI with the multiplexer (-m) inside a WebContainers (StackBlitz) browser environment, a single node-postgres Client connection fails with invalid frontend message type 47 on the server, and the client errors out (Command exited with code 1). The identical setup runs correctly on native Node.

Environment
  • @electric-sql/pglite 0.5.3, @electric-sql/pglite-socket 0.2.6
  • Runtime: WebContainers (StackBlitz), in-browser, Node v22.x
  • Server: npx pglite-server -m 10 -h 127.0.0.1 -p 5432 (default in-memory memory://)
  • Client: node-postgres (pg) 8.13.1
What we see
Initializing PGLite with database: memory://
Imported extension: pgcrypto
PGLiteSocketServer listening on {"port":5432,"host":"127.0.0.1"}
Client connected from 127.0.0.1:1
Client connected from 127.0.0.1:1
invalid frontend message type 47
Command exited with code 1

The client is a plain new Client({ connectionString: 'postgres://postgres:[email protected]:5432/postgres' }) running a sequential migration (BEGIN + a few CREATE TABLE/INSERT). 47 is 0x2F.

Ruled out
  • Not SSL — the client sets no ssl option and the DSN has no sslmode, so pg never sends an SSLRequest.
  • Not client-side concurrency — it's a single Client (not a Pool), connecting once and querying sequentially.
  • Works on native Node — the same migration against pglite-server -m on a normal Node host succeeds. So this looks specific to the WebContainers network stack interacting with the multiplexer's wire framing.
Repro sketch
  1. In a WebContainers/StackBlitz project: npx pglite-server -m 10 -h 127.0.0.1 -p 5432 --run "node client.mjs"
  2. client.mjs: connect a single pg.Client to 127.0.0.1:5432, await client.query('select 1').
  3. Observe invalid frontend message type 47 on the server.

Happy to assemble a minimal StackBlitz repro if it would help. Thanks for pglite + pglite-socket — the in-browser Postgres-wire server is exactly what we needed.

Lingua principale
TypeScript
Stelle
16.3k
Fork
474
Merge medio
23h 53m
PR unite (30g)
53

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di electric-sql/pglite

Tutte le issue di electric-sql/pglite

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.