When simulating close, ensure res emits close. #139
Merged
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.
In followup to #138 I've implemented the proposed fix. By looking at #138 you can see that the changes are nearly identical, but here we only handle the case of simulating a close rather than ensuring that res always emits
'close'
any time req emits'close'
.It's worth mentioning I also experimented with a separate approach of using the socket to propagate these events (as is done internally to node). My hope was that shot would then inherit a nice subset of node behaviors, and in turn be more accurate to a real/live http server. It was interesting and there were some positive results, but it was more complex and wasn't the right approach to address this particular issue.
Refs: hapijs/hapi#4208
I tested these changes with hapi against node v15.5.1, v14.15.4, and v12.19.1.