Skip to content

Another attempt at #129#133

Merged
devinivy merged 2 commits intohapijs:masterfrom
kanongil:destroy-fix2
Sep 2, 2020
Merged

Another attempt at #129#133
devinivy merged 2 commits intohapijs:masterfrom
kanongil:destroy-fix2

Conversation

@kanongil
Copy link
Contributor

This version is mostly identical to the old, except that it will now emit an out-of-spec 'close' event (ie. without a preceding 'end' or 'error' emit), when requested.

Additionally, the error emit, is now handled through calling destroy(), which is the correct way, and ensures that it respects the emitClose: true option.

This should behave identically to the existing implementation, except that it fixes the bug in hapijs/hapi#4149, and another exposed in 13a94e2, where 'close' & 'end' are emitted in the wrong order.

@kanongil kanongil added the bug Bug or defect label Aug 26, 2020
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The CI seems happy, and I tested this locally in hapi (both Node 12 and 14), and the previously seen failures appear to be resolved. I've requested reviews from a few other people.

@cjihrig cjihrig requested a review from Nargonath August 29, 2020 16:55
Copy link
Member

@devinivy devinivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good— I like that it carefully toes the line between leveraging real stream behavior while still allowing us to simulate contrived stream behaviors. I like having consistent autoDestroy behavior across node versions too, although I could also see merit in preserving weirdnesses for the purposes of ensuring those cases are covered by consumers of shot.

Copy link
Member

@nlf nlf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great! thanks for the second look, this looks ready to ship

devinivy added a commit to achingbrain/shot that referenced this pull request Sep 2, 2020
Co-authored-by: Alex Potsides <alex@achingbrain.net>
@devinivy devinivy added this to the 5.0.4 milestone Sep 2, 2020
@devinivy devinivy self-assigned this Sep 2, 2020
@devinivy
Copy link
Member

devinivy commented Sep 2, 2020

Thanks for your work @kanongil and everyone's careful review.

@devinivy devinivy merged commit e84429e into hapijs:master Sep 2, 2020
devinivy added a commit that referenced this pull request Sep 2, 2020
* fix: do not override destroy method

The node docs say:

> Implementors should not override this method, but instead implement readable._destroy()

Fixes hapijs/hapi#4149

* do not autodestroy request stream

* restore destroy method

* Revert changes in favor of #133, keeping new test

Co-authored-by: Alex Potsides <alex@achingbrain.net>

Co-authored-by: devin ivy <devin@bigroomstudios.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug or defect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants