Skip to content

HTTP Client 'aborted' event fires even when request was ok #18756

Closed
@billywhizz

Description

@billywhizz
  • Version: all versions from 4.x - > 9.x
  • Platform: Linux/Ubuntu 16.04 x64
  • Subsystem: http/https

We have been having issues with http/https downloads failing silently and the file being downloaded having an incorrect size for some time now. We are using axios library to do download and after some research and testing the only way we could get alerted about an incomplete download (connection is forcibly closed by server in middle of downloading body) was to handle the http response "aborted" event.

However, when we handled this we noticed we were having good downloads, where file contents were completely received, reported as "aborted".

Maybe this is intended behaviour but it makes more sense to me to only receive aborted event on a client response if the socket close happened before the active http response has been received completely. Currently, there is no check for the current active response having completed or not before firing the aborted event.

You can see the behaviour in this gist - the firing of the aborted event seems completely random and is likely due to timing of when the server closes the socket.

Our workaround is to use the commented code here to check if the current response is complete and ignore the aborted event if so.

Should the same logic be used in node.js core? Appreciate this could cause issues for existing libraries depending on current behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions