fix: issue #743 - close channel on Request 'aborted' event #744
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Checklist
What are you changing?
Ensure that the channel is closed if an API request is aborted (for example: back, reload etc. in the browser with the sample UI).
Anything the reviewer should know when reviewing this PR?
This is a placeholder really. See the issue for details about a 'better' fix to avoid the potentially moving target of which events are emitted by which object and when.
Note that the aborted event seems to be deprecated with later versions of nodejs. They suggest using 'close' instead, but that is called for every request. If that is the case, then it alone could be used and there would be no need to listen for 'finish' or 'close' on the response.
The unit tests have been improved test to ensure CloseChannel is called and listeners removed after a request 'completes'.