pubnub / javascript

PubNub JavaScript SDK docs https://www.pubnub.com/docs/sdks/javascript
Other
553 stars 401 forks source link

Any chance this libary will be updated to support Service Workers #308

Closed june07 closed 1 day ago

june07 commented 1 year ago

Using this in a chrome extension development:

https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj?hl=en https://microsoftedge.microsoft.com/addons/detail/nodejs-v8-inspector-ma/injfmegnapmoakbmnmnecjabigpdjeme

and moving to MV3 which uses ServiceWorkers and not background scripts... I'm running into issues with this library. I was able to get around a "window undefined" issue by setting listenToBrowserNetworkEvents to false, however another problem now is that the library uses superagent which in turn uses XHR. And unfortunately, XHR is not supported by MV3

Workers no longer provide XMLHttpRequest, but instead support the more modern fetch() https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/

So again, any feedback on this would be greatly appreciated.

montrosb commented 1 year ago

Our ad blocking extension also uses the PubNub library, and it would be extremely helpful if the JavaScript SDK supported Service Workers.

parfeon commented 1 day ago

The web version of the SDK uses the native Web Fetch API now and for special cases has a separate shared worker script for subscription to deal with browsers' limitations on active connections.