Skip to content

fix: return SSE responses through hapi's lifecycle - #7

Merged
Marsup merged 3 commits into
mainfrom
fix/marshal-response
Oct 21, 2026
Merged

Marsup merged 3 commits into
mainfrom
fix/marshal-response

Conversation

@damusix

@damusix damusix commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Handlers now return a hapi response that wraps the session's stream instead of writing to raw.res and abandoning. As a result, route cors/security settings and onPreResponse apply to SSE responses, and the refuse/complete paths send real 204s.

SSE responses are compressed when the client accepts gzip or deflate. SSE routes set hapi's compression route option to flush: Z_SYNC_FLUSH, so each event goes out as soon as it is written. Compression can be turned off with server compression: false, or for SSE only with a text/event-stream mime override.

onPostResponse now fires when the stream ends. A client disconnect is recorded as a 499.

Closes #6

Route cors/security headers and onPreResponse now apply to SSE
responses. Compression is disabled: zlib buffers events.

Closes #6
Comment thread test/marshal.test.ts Outdated
Comment thread API.md Outdated
@Marsup Marsup self-assigned this Oct 7, 2026
@Marsup Marsup added the bug Bug or defect label Oct 7, 2026
@Marsup Marsup added this to the 1.1.1 milestone Oct 7, 2026
SSE responses are compressed when the client accepts gzip or deflate,
flushed per event through the compression route option. Turn off with
server compression: false or the text/event-stream mime override.
@damusix
damusix requested a review from Marsup October 20, 2026 06:11
@Marsup

Marsup commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Requalifying as minor considering the changes.

@Marsup Marsup modified the milestones: 1.1.1, 1.2.0 Oct 21, 2026
@Marsup
Marsup merged commit d98fc65 into main Oct 21, 2026
3 checks passed
@Marsup
Marsup deleted the fix/marshal-response branch October 21, 2026 07:48
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.

SSE responses bypass hapi's response lifecycle

2 participants