electric-sql / electric-sql/pglite

Bun (Windows only): `SELECT bytea` > ~6 MiB returns empty result, works on Node.js & Bun/Linux

Open
#782 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
16k
Forks
442
Avg merge
20h 19m
Merged PRs (30d)
7

Description

**Summary:**
With `dataDir` backend, `SELECT file` (large `bytea`) returns empty results **only** in Bun on Windows. Inserts work; metadata and small slices work; full binary return fails. Same DB & code work in Node.js and Bun on macOS.

**Repro script (exact):**

```ts
import { PGlite } from '@electric-sql/pglite';
import { randomBytes } from 'node:crypto';

const db = await PGlite.create({ dataDir: './database' });
await db.query('CREATE TABLE IF NOT EXISTS issue (id INTEGER PRIMARY KEY, file bytea NOT NULL)');
await db.query('DELETE FROM issue');

// Works (5 MiB)
await db.query('INSERT INTO issue (id, file) VALUES (0, $1::bytea)', [
new Uint8Array(randomBytes(5 * 1024 * 1024)),
]);
console.log('file 0:', await db.query('SELECT file FROM issue WHERE id=0'));

// Fails (6 MiB) on Bun/Windows; works on Node/Bun/macOS
await db.query('INSERT INTO issue (id, file) VALUES (1, $1::bytea)', [
new Uint8Array(randomBytes(6 * 1024 * 1024)),
]);
console.log('file 1:', await db.query('SELECT file FROM issue WHERE id=1'));
```

**Observations (Bun/Windows):**

* `SELECT file WHERE id=0` (5 MiB) → returns `Uint8Array` as expected.
* `SELECT file WHERE id=1` (6 MiB) → `{ rows: [], fields: [], affectedRows: 0 }`.
* Data is present:

* `SELECT octet_length(file), pg_column_size(file) FROM issue WHERE id=1;` → correct sizes
* `SELECT substring(file FROM 1 FOR 1) FROM issue WHERE id=1;` → returns 1 byte
* Even textifying the full value fails:

* `SELECT encode(file,'hex') FROM issue WHERE id=1;` → empty result (on Bun/Windows)
* **Same code & DB work in Node.js and in Bun on macOS.**

**Hypothesis:**
Platform-specific bug in the **result return path** for large values from the PGlite WASM when running under **Bun on Windows** (binary/text payload over a size threshold). Might be interaction with Bun’s structured-clone/transfer.

**Environment:**

* PGlite: 0.3.7
* Bun (Windows): 1.2.21 or 1.2.22-canary.102+b7a6087d7
* Node.js (working): v22.14.0
* OS: Windows 24H2 (Build 26100.4946), macOS Tahoe 26.0 (working)
* Backend: `dataDir`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.