#833·pglite

Support for cursors / `pg-cursor`

Author: boredlandCreated Oct 31, 2025Updated Sep 13, 2026

When using pg-cursor with PGlite:

typescript
import { PGlite } from '@electric-sql/pglite';
import Cursor from 'pg-cursor';

const db = new PGlite();
const cursor = db.query(new Cursor('SELECT * FROM large_table'));
await cursor.read(100);

It fails because PGlite doesn't support the extended query protocol features needed for cursors, I think (TypeError: chunkReader.read is not a function, The "src" argument must be of type string. Received an instance of Cursor)

Use case

I'm trying to use PGlite for testing, while production uses PostgreSQL with cursor-based streaming (via pg-cursor).

Currently, I have to use a real PostgreSQL instance for tests that involve streaming, which defeats the purpose of using PGlite.

To Reproduce

  • PGlite version: 0.3.11
  • node version: v24.8.1

Expected behavior

Cursors should work similar to how they work with node-postgres + PostgreSQL, allowing:

  • Server-side cursors via DECLARE CURSOR
  • Portal-based result fetching with row limits
  • Batch processing of large datasets

Additional context

Maybe related to #223 (prepared statements) - both require extended query protocol support (Parse, Bind, Execute with row limits).