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

TypeError: URL is not a constructor #96

Closed
Oleksii14 opened this issue Nov 2, 2020 · 2 comments
Closed

TypeError: URL is not a constructor #96

Oleksii14 opened this issue Nov 2, 2020 · 2 comments

Comments

@Oleksii14
Copy link

I receive this error while trying to run checkDownloadSpeed

My code:

const assetUrl = '...'
  const sizeInBytes = 8000;

  const speedInMb = (
    await new NetworkSpeed().checkDownloadSpeed(assetUrl, sizeInBytes)
  ).mbps;
@wakingweb
Copy link

I was getting this error as well, ended up changing line 3 in app.js from:
const URL = require('url').URL;
to
const URL = require('url').Url;

After some digging and help, looks like this is related to defunctzombie/node-url#37

Ideally, the dependency on URL could be removed to work properly in browser environments.

@kenigbolo
Copy link
Owner

kenigbolo commented Mar 1, 2021

@wakingweb @Oleksii14 I've updated the package with a patch for this based on @wakingweb suggestion. The caveat however is that when using on clientside, it'll require HTTPS strictly (which IMO is should suffice) however, it'll continue to work on node same way as it previously did.

Updated the code sandbox link here https://codesandbox.io/s/red-rgb-lx1wr to show this in principle. I'll close this issue now, but thanks for letting me know about this, and sorry it took so long - new dad problems :)

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

3 participants