clone icon indicating copy to clipboard operation
clone copied to clipboard

Cannot clone a URL in Node >= 10

Open iambalaam opened this issue 5 years ago • 1 comments

The following code will run in node8, but break in node10 and node12.

const clone = require('clone');
const { URL } = require('url');
const url = new URL('https://example.com');

const url2 = clone(url);

It gives the following stacktrace

TypeError: Cannot set property 'flags' of undefined
    at URL.onParseComplete (internal/url.js:224:13)
    at URL.set [as href] (internal/url.js:443:7)
    at _clone (.../code/node-cache-fix/node_modules/clone/clone.js:162:16)
    at clone (.../code/node-cache-fix/node_modules/clone/clone.js:202:10)
    at Object.<anonymous> (.../code/node-cache-fix/clone-bug.js:5:14)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

iambalaam avatar Dec 15 '19 17:12 iambalaam

this causes node-cache/node-cache#127 just leaving this here so we get a ref to track this issue in the original issue thread

erdii avatar Dec 15 '19 23:12 erdii