comlink icon indicating copy to clipboard operation
comlink copied to clipboard

Explicitly mention in the document of Comlink's limitation on bidirectional communication between main thread and worker

Open dharshan-webdev opened this issue 1 year ago • 0 comments

There appears to be a fundamental limitation when attempting to use Comlink to enable bidirectional communication between the main thread and a worker thread simultaneously. Current behavior suggests that Comlink only supports unidirectional communication effectively, meaning that either the main thread can expose and the worker can consume, or vice versa, but not both ways at once. Explicit guidance on this in the documentation could help avoid confusion and save time troubleshooting.

Expected Outcome: It would be beneficial if the documentation could explicitly mention:

  1. Why Comlink does not support simultaneous bidirectional exposure (main ⇄ worker).
  2. Any underlying technical constraints, such as those related to structured cloning or transferables, that impact this behavior.
  3. Workarounds or best practices for developers needing two-way interaction.

dharshan-webdev avatar Nov 06 '24 19:11 dharshan-webdev