Skip to content

form-data >= 2.3.2 fragments data, causing delays #422

Closed

Description

@mildsunrise

If you run the following with form-data v2.3.2:

const form = new (require("form-data"))()
form.append("foo", "Some text")
form.append("bar", "Hmmm")
form.submit("http://example.com")

You will see that it first sends an incomplete chunk of data to the server:

POST / HTTP/1.1
content-type: multipart/form-data; boundary=--------------------------602269624292240232678615
Host: example.com
Content-Length: 273
Connection: close

----------------------------602269624292240232678615
Content-Disposition: form-data; name="foo"

Some text

After that, Nagle's algorithm kicks in and blocks the remaining data until the server sends an ACK. Then it's sent:

 
----------------------------602269624292240232678615 
Content-Disposition: form-data; name="bar" 
 
Hmmm 
----------------------------602269624292240232678615-- 

In conclusion, all requests made with form-data have at least 1 RTT of delay added to them. This may not seem much (146ms for me), but for servers that are far away and/or lots of requests, it has a substantial impact.

We have tracked this down to felixge/node-combined-stream#38. Before that PR, data chunks were written synchronously and Node.JS could buffer them into a single write to the socket. After the change, buffering is not possible.

Activity

  1. added a commit that references this issue on May 28, 2019
    61c2cab
  2. added a commit that references this issue on Aug 30, 2019
    556f097
  3. added a commit that references this issue on Aug 31, 2019
    5c6bf52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions