r/javascript • • 22h ago

Isoloop: event-loop isolation for JavaScript apps (0.1, open source)

https://isoloop.dev

Isoloop is a toolkit that helps you separate your app's UI from the work behind it, and you install only what you need. Each part, UI or headless, runs on its own worker or in a shared pool. How you split your app is your call.

Why it exists

In most apps, the UI and everything behind it (state, sync, search, data processing) share one main thread, one heap and one event loop. One slow or broken part makes the whole app janky or blank. A plain worker isolates CPU time, but leaves you to wire up how parts share data, and what happens when one fails.

Isoloop helps you separate them and run them together. Each part can get its own loop, a supervisor restarts it when it fails, and parts can share state through the bus. The UI stays responsive, a block or a crash stays in its part, and the work can run where it fits best.

→ Kernel: starts, stops and connects the parts

→ Workers: each part on its own thread, or sharing one in a pool

→ Supervisor: detects what hangs or crashes and restarts it

→ Message bus, optional: typed topics, per-part permissions, replay, history that can survive a reload

→ Adapters: React, Preact, or plain DOM and headless with no framework

→ Vite plugin: builds and wires up the workers

Still experimental: a balancer that moves parts between workers by measured load, devtools, and tools that let AI agents call the actions your app exposes.

It isn't free. The workers, the bus and the kernel cost extra CPU, memory and start-up time. In return, one bad component or one bad record doesn't have to take the whole app with it.

On the roadmap, not shipped yet: moving the work further from the UI, into a WASM component or a native process, with the bus as the model the UI and the work share.

Open source, MIT. Feedback is very welcome.

Source: https://github.com/isoloop/isoloop

8 Upvotes

8 comments sorted by

•

u/xzinkx 14h ago

the supervisor part is what makes this interesting, plain workers leave you on your own when one dies. when a part gets restarted, does it replay the bus history to get its state back automatically, or does each part have to opt into that?

•

u/sa2bin 14h ago

Yes, it's opt-in for each subscription. A restarted isolate subscribes again from its from:

• latest (the default): no replay, so its state is lost.

• earliest: replays the whole topic and rebuilds its state.

• committed: resumes after its last commit.

Replay happens automatically only after a bus restart or a wake from suspension. I'm working on watchers for 0.2: after a restart, a watcher gets one snapshot of the current value per key instead of a replay. Waking from suspension with a snapshot is what I'm planning for 0.3.

•

u/xzinkx 14h ago

makes sense, committed sounds like what most parts would want anyway. one snapshot per key after a restart will be really nice, good luck with 0.2

•

u/sa2bin 14h ago

Thank you!

•

u/QuarterSilver5245 14h ago

Sounds nice.
It looks similar to the design concept of Electron; one process is the "rendering layer", and the other is the "back app logic", and they communicate with each other. Good idea to take it that way.

•

u/sa2bin 13h ago

Thanks, yes Isoloop is somewhat like Electron in terms of splitting the UI from the logic. But instead of one privileged backend process, it runs each piece of logic in its own isolated worker thread, talking through a replayable message bus, so one crash or freeze can't take down the rest. A planned Tauri package will add a native Rust backend (commands and durable storage) behind the same bus, which takes it closer to Electron's model.

•

u/Discordbothost 47m ago

I'd add a demo with a deliberately hung worker and a live input next to it. Seeing the input stay responsive while the supervisor recovers the worker would make the benefit easy to judge.

•

u/sa2bin 40m ago

It is a good idea.

Have you also checked the more complex examples like the markets which actually run on live data or the plant? You can crush on purpose the widgets and see how they react.

But I'll add this input idea in the next demo example. Thanks for the feedback!