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

ReferenceError: MessageChannel is not defined #2984

Closed
0x446f6d opened this issue May 30, 2020 · 1 comment
Closed

ReferenceError: MessageChannel is not defined #2984

0x446f6d opened this issue May 30, 2020 · 1 comment

Comments

@0x446f6d
Copy link

Basic info:

  • Node.js version: v12.16.1
  • jsdom version: 16.2.2

Minimal reproduction case

const axios = require("axios");
const { JSDOM } = jsdom;
const channels = require('worker_threads');

async function main() {
    r = await axios.get("https://patrickhlauke.github.io/recaptcha/");
    if (r.error) {
        console.log("Eror occured - ",r.error)
    } else {
        const dom = new JSDOM(r.data,{
            url: "https://patrickhlauke.github.io/recaptcha/",
            contentType: "text/html",
            includeNodeLocations: true,
            runScripts: "dangerously",
            pretendToBeVisual: true,
            resources: "usable",
            beforeParse(window) {
                window.MessageChannel = channels.MessageChannel;
            }
        });
        console.log(dom.window.document);
    }
}

// Expected -> 'dom.window.document result'
// Actual ---> '(node:68114) UnhandledPromiseRejectionWarning: ReferenceError: MessageChannel is not defined'

How does similar code behave in browsers?

The result from dom.window.document (I didn't add a link to anything here since I assume everyone reading this knows, to some degree, the result of the above code.

@domenic
Copy link
Member

domenic commented Jul 10, 2020

Dupe of #2448

@domenic domenic closed this as completed Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants