Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Web Workers? #2020

Open
drewish opened this issue Oct 19, 2017 · 5 comments
Open

Support for Web Workers? #2020

drewish opened this issue Oct 19, 2017 · 5 comments
Labels

Comments

@drewish
Copy link
Contributor

drewish commented Oct 19, 2017

Basic info:

  • Node.js version: v8.6.0
  • jsdom version: 11.3.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const options = {
  url: "http://example.com/",
};
const dom = new JSDOM(`
  <!DOCTYPE html><html><head></head><body></div></body></html>
`, options);

var w = new dom.window.Worker("demo_workers.js");
var w = new dom.window.Worker("demo_workers.js");
        ^

TypeError: dom.window.Worker is not a constructor
    at Object.<anonymous> (/Users/andrew/projects/swagger-linter/no-worker.js:10:9)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
    at Function.Module.runMain (module.js:665:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:607:3

How does similar code behave in browsers?

You'd probably get the error that the file doesn't exist but Worker would be defined.

@jsdom jsdom deleted a comment from rrcobb Nov 3, 2017
@jcjolley
Copy link

+1

@TimothyGu
Copy link
Member

Can people refrain from adding +1 comments? They are not helpful.

Fixing this will depend on Worker support in Node.js core, which is already supported by Ayo.js but yet to be backmerged into Node.js. Both the primary author of the feature and I are unfortunately short on time to make this happen soon.

@kapouer
Copy link
Contributor

kapouer commented Jan 26, 2018

People like @jcjolley might have overlooked (being so overwhelmed by trump election) this 2016 github feature: reactions.

@RangerMauve
Copy link

Now that node supports the worker threads API should this be investigated again?

@segevfiner
Copy link

This would be quite cool to have, basically we will need our own Worker/SharedWorker classes that use the worker_threads inside with their own entry script that wraps around the user supplied script and creates a web worker like environment, e.g. importScript, self and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants