ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.57k stars 1.33k forks source link

Cannot catch error thrown by superagent #1640

Open StanleyWCTan opened 2 years ago

StanleyWCTan commented 2 years ago

Occasionally, superagent throws error from deep inside, however, its not catchable and cause the app to crash. So, is there a solution for catching the error? Thanks!

For example, requesting below 2 links will cause superagent to crash. target link: https://umwelthotel.at/index.php?id=78 or http://www.cargad.com/

try { let linkRes = await superagent.get(link).timeout({ response: 30000, deadline: 30000, }).set({"Accept-Encoding" : "gzip,deflate,sdch"}); if (linkRes && linkRes.text) { ..... } } catch (err) { // can not catch the error }

Maybe the abnormal localtion setting in response is the root cause:

image

image

joerybka-rand commented 2 years ago

@StanleyWCTan I am also running into this issue after it having worked for the past several years. Did you ever resolve this?

StanleyWCTan commented 2 years ago

@StanleyWCTan I am also running into this issue after it having worked for the past several years. Did you ever resolve this?

No luck :( I built a daemon for monitoring the app, restart it once it crached.