Skip to content

ClientRequest .abort() and ECONNRESET #32225

Closed
@ronag

Description

Continuing the discussion from #32182 (comment)

The current assumption is that always 'error' or 'response' is emitted on the socket.

However, this is not always the case. Consider:

const req = http.get(someUrl);
req.abort();
req.on('error', common.mustCall()); // Fails

This will fail because the case of calling req.abort() before 'socket' will actually result in no error. Whether we get an error or not is a question of timing.

The current semantics are:

  • If abort() before req.'socket', emit req.'close'.
  • If abort() after req.'socket' but before req.'response', emit req.'error'.
  • If abort() after req.'response', emit req.'close' & res.'aborted'.

My main concern (which breaks the above assumption) is the first scenario here. However, I noticed that fixing this will cause lots of other tests to fail.

What can/should we do about this? At a minimum I'd like to clarify the docs.

Metadata

Assignees

No one assigned

    Labels

    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