forwardemail / forwardemail/superagent

Multipart request (formData) can raise double callback

Open
#747 8 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

Hi,

I have encountered a problem with supertest, in the case we do request with attach (multipart) it will use a formData instance and this instance will be pipped to req : https://github.com/visionmedia/superagent/blob/master/lib/node/index.js#L1017.

But if for some reason the file is not completely uploaded and we send back a response (because of an error for example). This part of the code will be reached:

https://github.com/visionmedia/superagent/blob/master/lib/node/index.js#L862

And self.callback will be called . The connection will be closed, so req will raise an error event

[Error: write ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'write' (https://github.com/visionmedia/superagent/blob/master/lib/node/index.js#L731).

In the end the callback is called a second time.

Maybe I'm doing something wrong, Is this behaviour intended ?

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.