comlink icon indicating copy to clipboard operation
comlink copied to clipboard

Fixes issue #466

Open afbarbaro opened this issue 3 years ago • 4 comments

The fix is conceptually really simple: use a dynamic import (or require under cjs) to import MessageChannel from node's worker_threads module if we detect that the browser's instance of MessageChannel is undefined.

Nevertheless, this turned out to be more complicated that it should due to the lack of widespread support for TLA (top-level await). So, unfortunately, the fix is only available for the umd bundle, otherwise the esm bundle would just work on node and would break when running on browsers.

I've put comments on the code explaining that when TLA are widely available this can be fix for both module systems.

Overall, I'm not super thrilled with how this turned out. Open to feedback and ideas on how to improve it.

afbarbaro avatar Apr 01 '21 01:04 afbarbaro

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

google-cla[bot] avatar Apr 01 '21 01:04 google-cla[bot]

@googlebot I signed it!

afbarbaro avatar Apr 16 '21 21:04 afbarbaro

Would love to see this land!

eliellis avatar Oct 14 '21 20:10 eliellis

I'm beginning to do a scrub of PRs for merge candidates for the next version. State of feature support for Top Level Await has changed since this PR was initially posted, would someone be willing to take a second look at it now that we have TLA in node and all browsers?

benjamind avatar Jan 24 '23 18:01 benjamind