clone
clone copied to clipboard
Cannot clone a URL in Node >= 10
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)
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