by wey-gu on 6/6/25, 12:56 AM with 52 comments
by jauco on 6/6/25, 5:34 AM
by WhyNotHugo on 6/6/25, 11:12 AM
> No PostgreSQL install needed—just Node.js
postgres is 32MB, nodejs is 63MB. I know that 31MB isn't a huge deal for most folks, but it's hard to see as "doesn't require postgres" as a selling point when you need something else that's twice the size instead.
by samwillis on 6/6/25, 6:56 AM
I work on PGlite, we have an experimental WASI build that can run in a WASI runtime, it should enable dropping the Node requirement. It lacks error handling at the moment (WASM has no long jump, and Postgres uses that for error handling - Emscripten has hacks that fix this via JS), and so we haven't yet pushed it far.
Do ping me on our Discord and I can point you towards it.
Happy to answers any PGlite questions while I'm here!
by benpacker on 6/6/25, 12:05 PM
This is an example of a unit test of an API route on a fully isolated WASM backed Postgres - very few lines of code, and all your API unit tests can run fully in parallel without any shared state: https://github.com/ben-pr-p/bprp-react-router-starter/blob/m...
This is all of the code needed to use Postgres in prod and PGLite in test/dev: https://github.com/ben-pr-p/bprp-react-router-starter/blob/m...
by ptx on 6/6/25, 10:55 AM
by laurencerowe on 6/6/25, 5:03 AM
by veggieroll on 6/6/25, 2:49 PM
This is a nice project idea. But, you should use a Python WASM interpreter to run the PostgreSQL WASM.
by perrygeo on 6/6/25, 12:47 PM
by selimnairb on 6/6/25, 10:15 AM
by wey-gu on 6/6/25, 1:54 AM
by murkt on 6/6/25, 3:59 AM
by ForHackernews on 6/6/25, 11:21 AM
Because if you're really interested in testing postgres you can test PG in PG: https://pgtap.org/
by lucideer on 6/6/25, 9:50 AM
> The library automatically manages PGlite npm dependencies.
I'm sorry what? Please don't do this. There is no way you can do this in a way that:
(a) is compatible with every pre-existing in-repo NodeJS setup
(b) plays nicely with all SCA automation configurations (Dependabot, etc.)
---
Edit:
After closer inspection there's a config[0] to disable this which defaults to True, but no documentation on how to manage required Node deps when setting that value to false.
I would strongly suggest the authors default this to False with accompanying docs in the README
Overall though I do like the simplicity & readability of the codebase - it makes these gotchas really easy to find & verify even without docs - will definitely be using this.
[1] https://github.com/wey-gu/py-pglite/blob/b821cf2cfeb2e4bc58b...
by gleenn on 6/6/25, 3:36 AM
by jodiug on 6/6/25, 7:13 AM
It does depend on SQLAlchemy. Can this also be used with asyncpg? Is it on the roadmap?
by wg0 on 6/6/25, 7:50 AM
And now this.
Going to use right away.
by ArcaneMoose on 6/6/25, 5:31 AM
by wey-gu on 6/6/25, 12:56 AM
by buremba on 6/6/25, 1:35 PM
by ewhauser421 on 6/6/25, 4:46 AM
Anything that won’t work if you tried this as a drop in replacement for a full PG instance in tests? Maybe extensions? Any benchmarks?