electric-sql / electric-sql/pglite
[BUG] Crash (`RuntimeError: unreachable`) when opening existing `idb://` database created by previous pglite version
- Dominant language
- TypeScript
- Stars
- 16k
- Forks
- 442
- Avg merge
- 20h 19m
- Merged PRs (30d)
- 7
Description
### Description
We’re seeing a hard WASM crash when pglite tries to open an existing IndexedDB-backed database that was created by an earlier pglite / wasm build.
Instead of a recoverable error, the runtime aborts with:
```
RuntimeError: unreachable
at pglite.wasm:0x5154f8
…
```
This happens when:
* a database already exists in `idb://`
* pglite or its wasm build is upgraded (or extensions change)
* the same `dataDir` is reused
Creating the same database under a **new name** works immediately, which strongly suggests an on-disk compatibility issue.
### Version
Our currently used version is: `0.3.14`
### Expected behavior
Ideally one of:
* a clear error indicating an incompatible database format/version, or
* a guard that refuses to open incompatible IDB data instead of crashing the WASM runtime.
### Actual behavior
* WASM traps with `unreachable`
* No JS-level error is catchable
* Application crashes during worker init
### Notes
* This is reproducible without changing application logic.
* The issue also appears more frequently when using extensions (e.g. `vector`) and `idb://`.
* As a workaround, we are versioning the database name (`idb://name_vX`) and treating IDB storage as ephemeral.
### Suggestion
It would be very helpful if pglite could:
* embed a format / build version marker in IDB metadata, and
* fail fast with a descriptive error when opening incompatible data.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.