question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Web Worker Failing on Chrome

See original GitHub issue

Chrome 75.0.3770.100 Win 10 64-bit

I do the following:

var compressionOptions = {
          maxSizeMB: 0.8,
          maxWidthOrHeight: 1920,
          useWebWorker: true,
          exifOrientation: true
        };
const imageFile = await imageCompression(
          file,
          compressionOptions
        );

and get the following in browser console:

browser-image-compression.mjs:430 Run compression in web worker failed: x is not defined , fall back to main thread

Any ideas what could be wrong? The image is correctly compressed, but without a web worker.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
FaizanZahidcommented, Aug 5, 2019

@Donaldcwl i m having an issue when my browser adblock on chrome is turned ON , i get this error in console.

Refused to create a worker from ‘blob:https://site.com/3e9ce499-7750-4d8c-896b-7db16d4677c6’ because it violates the following Content Security Policy directive: “script-src ‘self’ * ‘unsafe-inline’”. Note that ‘worker-src’ was not explicitly set, so ‘script-src’ is used as a fallback.

(anonymous) @ browser.img.compress.js:1 (anonymous) @ browser.img.compress.js:1 (anonymous) @ browser.img.compress.js:1 (anonymous) @ browser.img.compress.js:1 browser.img.compress.js:1 Uncaught DOMException: Failed to construct ‘Worker’: Access to the script at ‘blob:https://site.com/3e9ce499-7750-4d8c-896b-7db16d4677c6’ is denied by the document’s Content Security Policy. at https://site.com/js/browser.img.compress.js:1:7705 at https://site.com/js/browser.img.compress.js:1:7770 at https://site.com/js/browser.img.compress.js:1:165 at https://site.com/js/browser.img.compress.js:1:169

Any way to fix this, i have even turned off use web worker option by false.

0reactions
Donaldcwlcommented, Mar 16, 2020

There should be no problem in v1.0.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does not Chrome allow Web Workers to be run in ...
The answer on Chrome can't load web worker says Chrome doesn't let you load web workers when running scripts from a local file....
Read more >
web workers on Chrome don't work locally - Google Groups
Hi Everyone, I've come across an issue that I am unsure is a problem with Chrome or my setup. Linked from the W3...
Read more >
443374 - Web Worker network requests blocked by main ...
Issue 443374: Web Worker network requests blocked by main thread in Chrome · 1. Estimate performance gain. · 2. Have some doc/plan about...
Read more >
Understanding and Using Web Workers - CODE Magazine
Instead, you have to open a new browser tab and navigate to chrome://inspect. The Dev Tools list on the left shows Shared Workers....
Read more >
Web worker fails to load in sandboxed iframe with Firefox 45
We see this behavior when using pdf.js to display PDF's inside a sandboxed iframe. Actual results: PDF.js fails to load the web worker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found