Closed wjpg closed 1 year ago
Just to establish what I uncovered in my investigation:
There's an extensive write up of this issue here: https://github.com/facebook/regenerator/issues/378.
The problematic code block exists in service-worker.js
, push-notifications-cdn.js
& push-notifications-esm.js
. It is from the 'regenerator-runtime' package, though in the pusher SDK I think it comes from the use of the babel '@babel/plugin-transform-runtime' plugin here:
https://github.com/pusher/push-notifications-web/blob/master/rollup/esm.js#L20
https://github.com/pusher/push-notifications-web/blob/master/rollup/service-worker.js#L21
https://github.com/pusher/push-notifications-web/blob/master/rollup/cdn.js#L21
It appears there was a fix released in a more recent regenerator-runtime version. tried forcing resolutions across @babel/runtime, @babel/plugin-transform-runtime & regenerator-runtime but that didn't have an impact
Updating to 2.0.0-beta.2 and adding globalThis.regeneratorRuntime = undefined
to service-worker.js
solved the issue.
I presume 2.0.0-beta.2 brought with it the updated regenerator-runtime package which includes this fix https://github.com/facebook/regenerator/pull/480/files#diff-798a682df82030e703dee15a6f36614fe31c1206bae21a66bbb6064d519e2981L736-R753
I was unable to find a solution on the current stable version 1.1.0
When using CSP headers - without "'unsafe-eval'" being permitted, push-notifications-web fails to initialise the client. Errors with more detail below. Note. We are already permitting
"https://js.pusher.com/beams/service-worker.js"
within a"script-src"
value.v 1.1.0 FIREFOX
It is hitting the
accidentalStrictMode
catch which I think is coming fromregeneratorRuntime
, within push-notifications-esm.jsCHROME
V 2.0.0-beta.2 CHROME:
FIREFOX: