Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Docs: Add guarantees about http request.abort #4409

Closed
GeorgeBailey opened this issue Dec 12, 2012 · 3 comments
Closed

Docs: Add guarantees about http request.abort #4409

GeorgeBailey opened this issue Dec 12, 2012 · 3 comments

Comments

@GeorgeBailey
Copy link

I was hoping that there would be language in the docs for http, something like "After a call to abort, no further events (error, response, data, end, etc) will be emitted on either the request or response objects."

I know that is not accurate, so please add to the docs what actually is accurate, and what actual handling I need to put in myself.

For now, I've been removing all the event listeners for error, response, data, end on both the request, and the response (if any) - adding back empty error handlers to prevent the 'unhandled exception' message.

jasnell added a commit to jasnell/node-joyent that referenced this issue Jun 24, 2015
Per nodejs#4409, the documentation on http.abort is a bit lacking.
This provides a slight improvement.
@jasnell
Copy link
Member

jasnell commented Jun 24, 2015

A PR has been opened for this. Closing the issue, will land the PR once it's reviewed.

@jasnell jasnell closed this as completed Jun 24, 2015
jasnell added a commit that referenced this issue Jun 26, 2015
Per #4409, the documentation on http.abort is a bit lacking.
This provides a slight improvement.

Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #25565
@jasnell
Copy link
Member

jasnell commented Jun 26, 2015

Fixed in b4a0ca2

@GeorgeBailey
Copy link
Author

@jasnell, thanks for your attention on this. I see the new wording.

request.abort()

Marks the request as aborting. Calling this will cause remaining data
in the response to be dropped and the socket to be destroyed.

From this I can assume that after req.abort() is called

  • No req response event is emitted
  • No res data event is emitted.

But there's still some ambiguity of what can still be emitted. I've been coding for worst-case on each of these 3 questions.

  • Could there still be a req error?
  • Would there still be a res end? (i.e. res data was already emitted before req.abort())
  • Would there ever be a res error?

Depending on the answers, application developers may be able simplify their code, otherwise such code is needed to prevent bugs in the applications.

jasnell added a commit to jasnell/node-joyent that referenced this issue Jun 29, 2015
Per nodejs#4409, the documentation on http.abort is a bit lacking.
This provides a slight improvement.

Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#25565
jasnell added a commit that referenced this issue Aug 4, 2015
Per #4409, the documentation on http.abort is a bit lacking.
This provides a slight improvement.

Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #25591
jBarz pushed a commit to ibmruntimes/node that referenced this issue Nov 4, 2016
Per nodejs#4409, the documentation on http.abort is a bit lacking.
This provides a slight improvement.

Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#25591
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants