forwardemail / forwardemail/superagent

Cannot catch error thrown by superagent

Open
#1,640 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

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](https://user-images.githubusercontent.com/23396064/132327402-61865569-ab06-48b8-8372-fd195be6f39e.png)

![image](https://user-images.githubusercontent.com/23396064/132327260-33097cf6-1094-4def-81da-0e0f4f6021a8.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.