ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.59k stars 1.33k forks source link

.attach() sends nothing in node 14 #1577

Closed puzrin closed 3 years ago

puzrin commented 4 years ago
    let res = await superagent
      .post('/')
      .field('url', 'http://example.com')
      .attach('config', path.join(__dirname, 'fixtures', 'config_custom.json'))
      .set('Accept', 'application/json');

This code works in node 10 & 12 as expected, but sends request without atachment in node 14.

Could you fix or suggest workaround?

puzrin commented 4 years ago

Ref https://github.com/form-data/form-data/issues/476

Seems problem in form-data.

niftylettuce commented 4 years ago

There's also this TODO https://github.com/visionmedia/superagent/blob/44fadf94e0b0a84276faeacc956eca7eb4d40abf/src/node/index.js#L1226 that is somewhat related.

puzrin commented 4 years ago

Not sure. That mode is when size can not be detected an not actually needed too much.

IMO problem is caused by multiple breaking changes in stream api. Reading "History" notes under headers shows many interesting things. For example, autoDestroy => true.

https://github.com/pillarjs/multiparty/commit/6afaf7aa02121d7542cc1d9f7b42a563d215e521#diff-168726dbe96b3ce427e7fedce31bb0bcR53 multiparty fixed bug with node v14, but i can't understand why this helps.

puzrin commented 3 years ago

Seems node 14 fixed at some moment. Not a problem anymore.