Bug: Uncaught error: "TypeError [ERR_INVALID_URL]: Invalid URL: https://"
See original GitHub issueUncaught error: TypeError [ERR_INVALID_URL]: Invalid URL: https://
Reproduction
See the PoC
const Koa = require("koa");
const fetch = require("node-fetch");
const app = new Koa();
app.use(async ctx => {
ctx.set("Location", "https://");
ctx.status = 301;
});
app.listen(3000);
(async () => {
try {
await fetch("http://localhost:3000");
} catch (error) {
console.log("catch");
}
console.log("done");
})();
Expected behavior
The PoC should print:
catch
done
Actual behavior
The PoC prints:
internal/url.js:257
throw new ERR_INVALID_URL(input);
^
TypeError [ERR_INVALID_URL]: Invalid URL: https://
at onParseError (internal/url.js:257:9)
at new URL (internal/url.js:333:5)
at ClientRequest.<anonymous> (/home/runner/UnfoldedShockingLocus/node_modules/node-fetch/dist/index.cjs:1291:52)
at ClientRequest.emit (events.js:310:20)
at ClientRequest.EventEmitter.emit (domain.js:482:12)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:596:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at Socket.socketOnData (_http_client.js:469:22)
at Socket.emit (events.js:310:20)
at Socket.EventEmitter.emit (domain.js:482:12) {
input: 'https://',
code: 'ERR_INVALID_URL'
}
Your Environment
software | version |
---|---|
node-fetch | 3.0.0-beta.7 |
node | 12.16.3 |
npm | 6.14.4 |
Operating System | Linux |
Issue Analytics
- State:
- Created 3 years ago
- Comments:10
Top Results From Across the Web
mongodb - TypeError [ERR_INVALID_URL]: Invalid URL
I got below error. I am new to nestjs. Please help me to find the error TypeError [ERR_INVALID_URL]: Invalid URL ...
Read more >Uncaught error: "TypeError [ERR_INVALID_URL]: Invalid ...
Bug : Uncaught error: "TypeError [ERR_INVALID_URL]: Invalid URL: https://"
Read more >Node.js Client TypeError [ERR_INVALID_URL]: Invalid URL
Hello, I am trying to deploy a 1Password Connect Server via Docker as per your instructions but, I am getting the following error...
Read more >Concerning error "Invalid URL" - Bug Reports
I tried opening the dev tools (ctrl-shift-i) but there were no errors reported on the console. [Main Exception] Invalid URL TypeError [ ...
Read more >TypeError: Failed to construct 'URL': Invalid URL (Example)
Hello, I'm attempting to use images and videos in my react component and I'm receiving one of two errors. Where I try the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, now it makes sense. If you just described it same way in your issue.
this have been fixed with a try/catch and
manual
no longer throws for those who wish to manually handle wrong urls in the location header