fetch doesn’t handle try/catch when http2 request fails
See original GitHub issueany ideas how to fix this in pooledMap? I wrapped my entire fetch request with Try catch and it still crashes
TypeError: error sending request for url (https://briskreader.com/api/1/fetch?url=https://www.scmp.com/news/hong-kong/law-and-crime/article/3157622/hong-kong-emergency-services-search-hiker-missing?utm_source=rss_feed): http2 error: connection error received: not a result of an error
at async mainFetch (deno:ext/fetch/26_fetch.js:266:14)
error: Uncaught (in promise) AggregateError: Threw while mapping.
new AggregateError(errors, "Threw while mapping."),
^
at https://deno.land/std@0.115.1/async/pool.ts:63:9
this happens if my api goes down while I’m trying to send a request to it…if nginx doesnj’t server a 200 then my script crashes
i’m using systemd and if i crash the api it restarts, but during that time my pooledMap crashes from my script.
i basically did try { ... fetch() } catch(err) { return Promise.resolve() }
doesnt’ seem to work with pooledMap
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Try-Catch not handling errors with an https.get request in Node
The reason why try...catch.. fails is that it is meant for handling synchronous errors. https.get() is asynchronous and cannot be handled ...
Read more >Handling Failed HTTP Responses With fetch() - TJ VanToll
Per MDN, the fetch() API only rejects a promise when a “network error is encountered, although this usually means permissions issues or similar....
Read more >Fetch - Error Handling for Failed HTTP Responses and ...
A quick example of how to handle both network errors and HTTP errors (4xx or 5xx) for fetch requests in a single catch...
Read more >Errors | Node.js v19.3.0 Documentation
js supports several mechanisms for propagating and handling errors that occur while an application is running. How these errors are reported and handled...
Read more >Error in curl::curl_fetch_memory(url, handle = handle ... - GitHub
Everything seems to work fine, but occasionally I get the error message "Auto-refreshing stale OAuth token." followed by the more cryptic error ......
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 Free
Top 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
So I guess my fetch pattern sucked and doesn’t do what I thought it did.
I replaced:
with a real try/catch:
and now it doesn’t crash.
I also get this error sometimes:
TypeError: Fetch failed: Maximum number of redirects (20) reached
try/catch is ignored