Summary
Currently, the SharedWorker processes all incoming requests in parallel. This leads to high connection overhead and degraded performance.
Problem
Because each message triggers network requests independently, multiple WebSocket or RPC connections may open at once, overloading both the client and remote nodes.
Proposed Solution
Implement a task queue within the SharedWorker so that incoming requests are:
- Added to a queue.
- Processed sequentially (or optionally with limited concurrency).
- Automatically trigger the next task once the current one completes.
Benefits
- Prevents connection flooding.
- Reduces RPC load and improves overall performance.
- Keeps compatibility with existing message handling logic.