BuilderIO / partytown

Relocate resource intensive third-party scripts off of the main thread and into a web worker. 🎉
https://partytown.builder.io
MIT License
12.98k stars 429 forks source link

Probably broken in Dev & Canary Chrome Builds #55

Closed lincolnthree closed 2 years ago

lincolnthree commented 2 years ago

Please be advised: https://bugs.chromium.org/p/chromium/issues/detail?id=1078821

Error: Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost/...' failed to load.

As a quick summary, this bug affects Workers that call importScripts() and are loaded from localhost or constructed from a data/Blob URL. E.g. Essentially anything using WebPack running in Cordova or Ionic Capacitor.

The above bug will likely break this package (and any use of Worker in production WebPack apps) if it is not fixed before affected Chrome Dev & Canary builds get to the production / stable branch. It does not appear to be a bug in the Partytown package at this time. I do not know if there are any workarounds.

I am calling attention to this so that anyone here who depends on Workers actually working in production will see this coming ahead of time, and maybe bring some more priority to the issue over at Chromium. Please add any feedback you have to that issue / star / vote for this issue in the Chromium bug tracker

And for anyone else who comes here looking for why Workers are broken, if you get an error about importScripts(), this is probably why.

Thank you! Feel free to close this issue if it is not helpful.

adamdbradley commented 2 years ago

Looks like the most recent comment said it's fixed now? Are you still seeing an issue?

lincolnthree commented 2 years ago

Hey! Perhaps a mixed blessing, while I have no confirmation from the Google team that the fix was intentional, it does appear to be working. There are, however, still several outstanding issues (linked) related to this that will likely have the same outcome in other environments - e.g. Chrome on Windows running against localhost. Still hoping they will acknowledge this. That's all I know at this point. I re-tested the newer (pre-release) WebView implementations and can no longer reproduce the issue.