Skip to content

Conversation

@kanongil
Copy link
Contributor

It seems that hapi has a major issue with stream responses, where stream.destroy() is called on it before it has ended. More specifically, it will essentially ignore the destroy(), and never end the response stream (unless a server timeout has been configured). Since users control the stream they return, it is likely that this can happen for them.

The main fix is to treat stream 'close' as an aborted response.

A secondary fix is need to handle when the stream is internally piped through eg. a compressor. This is because stream.pipe() only forwards the 'end' event, which never happens once destroyed.

Note that it is only the first test that exposes the breakage. The second test is for added test coverage (and verification).

I haven't checked if this fix has any impact on #4244.

@kanongil kanongil added the bug Bug or defect label Aug 10, 2025
@kanongil kanongil force-pushed the handle-stream-destroy branch from d6e6c91 to 2739457 Compare August 11, 2025 08:07
@Marsup Marsup added this to the 21.4.3 milestone Aug 13, 2025
@Marsup Marsup merged commit 37d211a into hapijs:master Aug 13, 2025
10 checks passed
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.

2 participants