Coder Social home page Coder Social logo

Malformed chunked response detector creates false-positive ‘premature close’ errors when HTTP Agent involved about node-fetch HOT 1 OPEN

steveluscher avatar steveluscher commented on June 10, 2024 4
Malformed chunked response detector creates false-positive ‘premature close’ errors when HTTP Agent involved

from node-fetch.

Comments (1)

Yogu avatar Yogu commented on June 10, 2024 1

I needed to debug the issue in order to understand this issue, but I think I do now. Just posting this comment to re-phrase the issue in my words, maybe it helps someone else. You mentioned it in #1576 with this comment

If you folks are using an http.Agent with your connections in keepAlive mode with a fixed number of maxSockets, #1767 is the problem.

and this actually means "if these conditions are met, you will always encounter the issue" (so this issue here) regardless of chunk/content lengths (what was discussed in #1576)

The reasons seems to be: node-fetch assumes that the body 'data' event fires before response 'close' event. This is not true when an agent wants to reuse a connection where the request already completed, but the consumer has not read the body yet. Seems like node does not wait for the consumer to actually consume the response body and instead reads and buffers it.

from node-fetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.