Open arseneyr opened 4 years ago
Should've patched all the port creations, but maybe I left something out
If you want to debug, I'd log the messages that are sent and that should reveal more
I believe this is a race condition in forward()
:
Specifically, the port
promise can resolve after a message has already been received and is lost. I'm not too familiar with Javascript internals but I assume it's an implementation detail whether the promise is resolved first or the message is processed.
I've opened #3 to make forward()
sync and callers to use callbacks instead.
I'm having issues when calling two methods on the same proxied object and waiting on the results simultaneously. I have a minimal repro here (run
yarn start
and load the extension in thebuild
folder) but here is the gist of it:The promise returned by
s.getB()
never resolves. The interesting thing is that changing the order of the promises (i.e. callinggetA()
beforegetSubProxy()
) works fine. Also this is not a problem when using Comlink and web workers directly. Am I doing something obviously wrong here?