GoogleChromeLabs / comlink

Comlink makes WebWorkers enjoyable.
Apache License 2.0
11k stars 382 forks source link

fix: Safer check before calling start() #656

Open tmcw opened 4 months ago

tmcw commented 4 months ago

In both of these cases, the ep variable is the scope, and in some cases there'll be a start() method available, and we want to call it. I'm not sure exactly why - such a method doesn't show up in GlobalWorkerScope but maybe it's somewhere else.

However, there might also just be a variable called start in your global scope, and it isn't a function, and Comlink will expect it to be callable. This PR compensates for that case by making sure that the value is a function before calling it.