Skip to content

Question: Is bidirectional streaming with persistent isolates/workers in scope? #63

Description

@kartikey321

Summary

I wanted to ask whether true bidirectional streaming with a persistent isolate is in scope for this package,
or part of any future roadmap.

My concrete use case is a persistent WebSocket-style workflow:

  • keep message handling/state syncing/parsing logic inside a long-lived isolate or worker
  • let the main isolate send outbound events/control messages to it at any time
  • let the isolate/worker continuously emit processed/parsed data back to the main isolate
  • avoid tying this communication to a single compute() request/response lifecycle

In other words, I am looking for a persistent channel where both sides can send messages independently.

Why I am asking here

I found packages such as stream_isolate and typed_isolate that cover similar bidirectional isolate
communication on native Dart/Flutter platforms.

The reason I am asking here is that isolate_manager already has a broader cross-platform story around VM
isolates, Web Workers, and WASM. So I wanted to understand whether a stream-first bidirectional API fits this
package’s scope.

Current model

From reading the package, IsolateManager currently seems centered around a task queue model:

final result = await isolate.compute(input);

createCustom supports multiple outputs during a task through controller.sendResult() and callback, which is
useful for progress/result streaming. But the lifecycle still appears tied to an active compute() call and
final callback completion.

For my use case, the desired shape is closer to a persistent channel/actor model:

  final bridge = await IsolateBridge.spawn<Input, Output>(worker);

  bridge.output.listen((event) {
    // processed/parsed data from worker -> main
  });

  bridge.send(input);       // outbound event/control message main -> worker
  bridge.pipe(inputStream); // optional Stream<Input> -> worker

Inside the worker:

  void worker(bridge) {
    final socket = /* persistent websocket or socket-like source */;

    bridge.input.listen((message) {
      // main -> worker control/outbound event
      // update state, send over socket, etc.
    });

    socket.listen((rawMessage) {
      final parsed = parseAndApplyState(rawMessage);
      bridge.send(parsed); // worker -> main processed data
    });
  }

Question

Is this kind of bidirectional streaming / persistent channel API something you would consider in scope for isolate_manager?

If yes, I would be interested in discussing a possible design before attempting an implementation.

If not, that is also totally fine, I can treat it as a separate abstraction built specifically around stream-to-stream isolate communication.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions