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.

Uncaught TypeError: Failed to construct 'Worker'

See original GitHub issue

I tried minimum example. (on Chrome 69/Mac)

// src/index.js
const worker = new Worker("./worker.js", { type: "module" });
worker.onmessage = event => {
  console.log("response: " + event.data);
};
worker.postMessage(0);
// webpack.config.js
const HTMLPlugin = require("html-webpack-plugin");
const WorkerPlugin = require("worker-plugin");

module.exports = {
  mode: process.env.NODE_ENV || "development",
  plugins: [new HTMLPlugin(), new WorkerPlugin()]
};

Compile success but I got this error on browser.

Uncaught TypeError: Failed to construct 'Worker': Module scripts are not supported on DedicatedWorker yet. You can try the feature with '--enable-experimental-web-platform-features' flag (see https://crbug.com/680046)
    at Object.<anonymous> (main.js:9346)
    at Object../src/index.js (main.js:9354)
    at __webpack_require__ (main.js:20)
    at Object.0 (main.js:9366)
    at __webpack_require__ (main.js:20)
    at ./node_modules/ansi-html/index.js.module.exports (main.js:84)
    at main.js:87

Build result is here

/* WEBPACK VAR INJECTION */(function(__webpack__worker__1) {const worker = new Worker(__webpack__worker__1, { type: "module" });
// ...

I tried enable-experimental-web-platform-features but it does not work too. (and ChromeCanary too)

I think, it is lack of some pre-conditions.

My full code is here https://github.com/mizchi-sandbox/try-worker-plugin

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

0reactions
developitcommented, Oct 9, 2018

Fix released in 1.1.0!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught DOMException: Failed to construct 'Worker': Script ...
If you are seeing this in Chrome then the answer probably has to do with loading from a local filesystem rather than over...
Read more >
Failed to construct 'Worker': Script at ... cannot be accessed ...
Hello, my web-worker doesn't load in production when use different servers for app and assets 16.8e953915c614.js:1 Uncaught DOMException: ...
Read more >
Unable to create memory game – JS errors - WordPress.org
Uncaught TypeError : Cannot read property 'makeTabbable' of undefined at ... Uncaught DOMException: Failed to construct 'Worker': Access to the script at ...
Read more >
Failed to construct 'Worker': Access to the script at 'blob ...
Hi, I am getting an error while importing meshes while host the project in a particular server. I am not getting this in...
Read more >
Getting Failed to construct 'Worker' with JS worker file located ...
How to resolve "Uncaught TypeError: Failed to construct 'Comment': Please use the 'new' operat....." with respect to React JS? ... How can i...
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