koajs / discussions

KoaJS Discussions
2 stars 2 forks source link

long streams get randomly broken #21

Open BananaAcid opened 5 years ago

BananaAcid commented 5 years ago

This is since the middle of last year - transferring large files on slow connections, I get an error:

Error: You cannot pipe after data has been emitted from the response.

Any chance this gets replaced? always need to monkey patch. Quite annoying.

  Error: You cannot pipe after data has been emitted from the response.
      at Request.pipe (C:\blog\app-ui\node_modules\request\request.js:1478:26)
      at respond (C:\blog\node_modules\koa\lib\application.js:240:43)
      at handleResponse (C:\blog\node_modules\koa\lib\application.js:149:34)

Solution: Do not use Koa ctx.body = stream. Return the stream directly. Code here: https://github.com/koajs/koa/issues/944#issuecomment-334961426

fl0w commented 5 years ago

I'm not sure how Koa should fix an issue in request package?

BananaAcid commented 5 years ago

By replacing it, since it reached EOL anyways. The appended link shows more about this issue.

No further development: https://github.com/request/request/issues/3142

Alternatives: https://github.com/request/request/issues/3143