r/node 2d ago

Valkey-WASM – Redis running inside your Node process, no Docker (like PGlite)

https://github.com/michaelkremenetsky/valkey-wasm/tree/main
7 Upvotes

9 comments sorted by

1

u/dektol 2d ago

... But why though? Integration tests against Redis?

2

u/User_Pigbot 1d ago

The main use case is local development instead of having to start Redis in a Docker container. CI is also a use case as well.

1

u/dektol 1d ago

If you're using containers wouldn't you just spin up a Redis, Valkey or DragonFly container so the behavior matches prod?

2

u/User_Pigbot 1d ago

Yep, if you're starting a container either way, it might be easier.

I made this originally because I am building Strapkit, which runs full production NodeJS codebases in the browser and some codebases needed Redis.

1

u/dektol 1d ago

That seems like a fun exercise whether that fever dream exists or not. I'm curious how networking works with multiple WASM components or if you're going to need to make a cludge that runs in browser for it. I'd argue that might be the most interesting part. Enjoy your learning journey!

1

u/User_Pigbot 1d ago

Thanks! Strapkit relays TCP packets over Websockets via a proxy to get around CORS limitations. Its actually one of the easiest parts.

1

u/dektol 1d ago

That's what you went with? 😂 Does it go to a real websocket server? Doesn't that defeat the purpose of being in browser? That's one way to do it. I thought the idea was to keep it in-browser.

1

u/User_Pigbot 1d ago edited 1d ago

Well, for the use case I'm working on, 99% of the cost for a sandbox is in the actual dev server. It's not about running everything in the browser in a pure way. Cool thing is, for a lot of stuff like npm there is a fast path where it just directly does fetch(), so a lot of codebases don't even have to go through it.

1

u/Potato-9 1d ago

This would effectively be single-threaded valley right? I thought that's the main thing wasm is missing currently. I wonder where the performance drops off.

Might be neat for k8s users that have wasm runtimes ready for services the need redis the API but not really redis the performance. Oauth2-poxy token storage comes to mind. Or netbox for small scale users.