Skip to content

response.body should fail if server terminates connection before response is fully transmitted #1055

@Gozala

Description

@Gozala

If server terminates connection before response is fully transmitted that should cause an error. In fact that seems to be the case when consuming the response e.g. via response.text() API. However if response.body is used directly via for await loop no errors are reported.

Reproduction

Test case is provided by #1056

Expected behavior

Following code should log error if connection is terminated before transmission is complete, instead loop is complete without any errors

try {
  for await (const chuck of response.body) {
    // ...
  }
} catch(error) {
  console.error(error)
}

Screenshots

Same code in browsers produces error as expected here is an example (querying same server) as the attached test:

Screen Shot 2020-12-31 at 5 27 15 PM

Your Environment

software version
node-fetch master
node v12.18.2
npm 6.14.5
Operating System Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions