GoogleChromeLabs / comlink

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

feat: call "waitUntil" when exposed from "ExtendableEvent" #658

Closed mrpelz closed 3 months ago

mrpelz commented 3 months ago

When exposing from a Service Worker, calling async methods requires handing the resulting Promise to the ExtendableEvent’s waitUntil method, in order to ensure their execution.

surma commented 3 months ago

I see where you are coming from, but I don’t think this should be the default behavior, esp without opt-out. I think transfer handlers let you do this right now without having to patch Comlink.

mrpelz commented 3 months ago

Oh, I didn’t consider that TransferHandler’s deserialize method (which would then be used to augment the Service Worker’s handling of messages) is called with the whole ExtendableEvent.

Thanks. :)