Consensys / armlet

a MythX API client wrapper
MIT License
16 stars 7 forks source link

Uncaught TypeError: url.URL is not a constructor #103

Closed aquiladev closed 5 years ago

aquiladev commented 5 years ago

I have an error on application startup when I import armlet package image

$ npm -v 6.4.1 $ node -v v10.15.1

muellerberndt commented 5 years ago

At first sight simply replacing url.URL with URL and not explicitly importing the url package seems to work fine. Is there any reason this could break stuff elsewhere?

aquiladev commented 5 years ago

does not work in my case removing the import of url const url = require('url') works (node v10.15.1)

/util.js

/**
 * Wait for the specified time.
 *
 * @param {Number} time Interval duration [ms].
 * @return {Promise} Resolves after the specified delay.
 */
exports.timer = async time =>
  new Promise(resolve => setTimeout(resolve, time))

exports.joinUrl = (base, path) => {
  const u = new URL(path, base)
  return u.href
}
muellerberndt commented 5 years ago

I put in another PR which I think fixes the issue, see #105 #106.

vdenisov-pro commented 4 years ago

The problem occurs because url.URL is undefined (read more in this comment).