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

DOMParser is not defined error when initializing client in Web Worker #401

Open
1 of 2 tasks
adamra-msft opened this issue Sep 30, 2020 · 5 comments
Open
1 of 2 tasks
Assignees

Comments

@adamra-msft
Copy link

Package Version: 2.0.8

  • nodejs
    • nodejs version: ______
    • os name/version: _____
  • browser
    • name/version: Chrome Version 85.0.4183.121

Describe the bug
When initializing a ms-rest-js client within a web worker, an error is thrown: DOMParser is not defined. DOMParser is not available within a web worker. This prevents the client from being used from within a web worker.

To Reproduce
Steps to reproduce the behavior:

  1. Create a web worker using code similar to the following (substitute ClientName, token, and customBaseUri for valid values--ClientName should be a client derived from msRest.ServiceClient; the other values might be optional depending on the client that is tested)
onmessage = () => {
  const client = new ClientName(new TokenCredentials(token), {
    baseUri: "customBaseUri"
  });
};
  1. Send a message to the web worker to invoke this code
  2. Note error logged in browser console:
Uncaught ReferenceError: DOMParser is not defined
    at Module.../../node_modules/@azure/ms-rest-js/es/lib/util/xml.browser.js (xml.browser.js:3)
    at __webpack_require__ (bootstrap:19)
    at Module.../../node_modules/@azure/ms-rest-js/es/lib/policies/deserializationPolicy.js (deserializationPolicy.js:1)
    at __webpack_require__ (bootstrap:19)
    at Module.../../node_modules/@azure/ms-rest-js/es/lib/serviceClient.js (serviceClient.js:1)
    at __webpack_require__ (bootstrap:19)
    at Module.../../node_modules/@azure/ms-rest-js/es/lib/msRest.js (msRest.js:1)
    at __webpack_require__ (bootstrap:19)

Expected behavior
The client should initialize successfully within a web worker.

Screenshots
Screenshot of error in browser console:
image

Additional context
N/A

@jeremymeng jeremymeng self-assigned this Jan 26, 2021
@jeremymeng
Copy link
Member

@adamra-msft We use DOM api to parse and build XML in browsers. Web Worker don't have access to DOM api. We are still investigate a proper fix. In the mean time, would the workaround suggested here work for you?

@rathboma
Copy link

rathboma commented May 4, 2021

@jeremymeng I am having the same issue in Beekeeper Studio. The workaround suggested in the core-http issue did not work for me.

@rathboma
Copy link

rathboma commented May 4, 2021

I'm only looking to use the node-mssql library which depends on tedious. I'm not sure why they need this library, but so it is.

@jeremymeng
Copy link
Member

@rathboma if possible, could you please provide a simple project that demonstrates the issue when using node-mssql? That would help our investigation greatly!

@rathboma
Copy link

rathboma commented May 4, 2021

So this isn't a self-contained reproduction, but Beekeeper is FOSS, so if you are able you can check out this branch:

Then yarn install, yarn electron:serve to start it,
you can connect to any database, the easiest is Beekeeper's own db: help -> add Beekeepers Db
Then go to a table, right click, export. You'll see the error in the console.

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

Successfully merging a pull request may close this issue.

3 participants