forwardemail / forwardemail/superagent
"superagent: double callback bug" with timeout
- Dominant language
- JavaScript
- Stars
- 16.6k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
## Describe the bug
**Node.js version:** v18.16.0
**OS version:** ubuntu 22.04
**Description:**
When a request aborts with a timeout, it calls the callback twice resulting in a message being printed on the console "superagent: double callback bug"
## Expected behavior
Should not print the console message and should not call the callback twice
## Code to reproduce
```
const superagent = require('superagent');
(async function () {
try {
await superagent.get('https://some/slow/api').timeout(20000);
} catch (error) {
console.log(error);
}
})();
```
Output (with DEBUG=*) :
```
superagent GET https://some/slow/api +0ms
superagent GET https://some/slow/api -> 200 +5s
Error: Timeout of 20000ms exceeded
at RequestBase._timeoutError (/home/yellowtent/box/node_modules/superagent/lib/request-base.js:712:17)
at Timeout. (/home/yellowtent/box/node_modules/superagent/lib/request-base.js:727:12)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7) {
timeout: 20000,
code: 'ECONNABORTED',
errno: 'ETIME',
response: undefined
}
superagent: double callback bug
```
## Checklist
- [X] I have searched through GitHub issues for similar issues.
- [X] I have completely read through the README and documentation.
- [X] I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
Contributor guide
Assessment
This issue has not been assessed yet.