Polka always running onError handler
See original GitHub issueI am using polka v0…5.0 and here is my code
import polka from 'polka';
const httpserver = polka({
onError: (e) => {
console.log('Error handling request');
console.log(e);
}
});
httpserver.get('/', (req, res) => {
console.log('Request received');
res.end('Hello World!');
})
httpserver.listen(3000, err => {
if(err) {
console.log(err);
}
})
When I access the route ‘/’, I can see “Request received” in terminal and “Hello world” in browser but Polka is also running onError handler each time I access ‘/’ route with error 404. Why polka is running onError handler even there is no un-handled exception in route handler.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
polka - Bountysource
This happens because the first subapp responds with 404 (e.g. calls no match handler) and therefore doesn't switch to the next app, resulting...
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
Thank you, Luke.
Hi @zolotokrylin,
You’re creating an Error object but you never
throw
it. It’s likenew Cat
but never assigning it to a variable.You should check out these docs for info