forwardemail / forwardemail/superagent

regression: exceptions in client callback handler cause callback to be re-invoked

Open
#1,314 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

https://github.com/visionmedia/superagent/commit/092e3d6d289f90af2551540a5fbcdf771ca9b7fe commit appears to have introduced an issue:

If the callback invoked after the request completes throws an exception, the callback is invoked a second time. This is particularly painful for testing with something like `supertest` when you want to assert something after an API request. The test assertions failures are caught by `superagent` and the callback is re-invoked (typically not a good idea). The end result is difficult to understand execution.

```javascript
supertest(server)
.post('/range')
.send('some data')
.expect(201)
.end(err => {
assert.isTrue(someThing);
done();
});
```

God forbid you end up in an infinite loop!

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.