Skip to content

[BUG]: PGLiteSocketServer swallows errors on startup #964

@recursiveGecko

Description

@recursiveGecko

Describe the bug

PGLiteSocketServer.start() Promise swallows startup errors and hangs indefinitely. There's no log output unless debug: true is enabled.

To Reproduce

const { PGlite } = require('@electric-sql/pglite');
const { PGLiteSocketServer } = require('@electric-sql/pglite-socket');

const main = async () => {
  console.log('Starting PGLite');
  const db = await PGlite.create('memory://');

  console.log('PGLite started');

  server = new PGLiteSocketServer({
    db,
    path: '/this/path/does/not/exist',
    debug: true
  });

  console.log('Waiting for PGLiteSocket to start...');
  await server.start();

  console.log("Started succesfully. Exiting.");
  await server.stop();
  await db.close();
}

const timeout = setTimeout(() => console.log('timed out'), 3600_000);
main().finally(() => clearTimeout(timeout));

Logs

# node index2.js 
Starting PGLite
PGLite started
[PGLiteSocketServer] constructor: created server on /this/path/does/not/exist
[PGLiteSocketServer] constructor: max connections: 1
Waiting for PGLiteSocket to start...
[PGLiteSocketServer] start: starting server on /this/path/does/not/exist
[PGLiteSocketServer] start: server error: Error: listen EACCES: permission denied /this/path/does/not/exist
    at Server.setupListenHandle [as _listen2] (node:net:1986:21)
    at listenInCluster (node:net:2065:12)
    at Server.listen (node:net:2187:5)
    at /home/user/tmp/pglite/node_modules/.pnpm/@electric-sql+pglite-socket@0.1.3_@electric-sql+pglite@0.4.3/node_modules/@electric-sql/pglite-socket/dist/index.cjs:1:8566
    at new Promise (<anonymous>)
    at m.start (/home/user/tmp/pglite/node_modules/.pnpm/@electric-sql+pglite-socket@0.1.3_@electric-sql+pglite@0.4.3/node_modules/@electric-sql/pglite-socket/dist/index.cjs:1:8321)
    at async main (/home/user/tmp/pglite/index2.js:17:3) {
  code: 'EACCES',
  errno: -13,
  syscall: 'listen',
  address: '/this/path/does/not/exist',
  port: -1
}

[.... hangs forever ...]

Details

  • PGlite version 0.4.3
  • OS version Linux ccode 6.12.74+deb13+1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.74-2 (2026-03-08) x86_64 GNU/Linux
  • Node v25.9.0

Additional context

I think this condition needs to be flipped but I'm not sure if there's another reason why it's written this way:

https://github.com/electric-sql/pglite/blame/16bd20dff506fcf0e7a7d247d514c494ddfabefa/packages/pglite-socket/src/index.ts#L613-L615

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions