Skip to content

fix(server): send SSE-friendly headers on /hyper/events#35

Closed
jtlocsei wants to merge 1 commit into
dynamic-alpha:mainfrom
jtlocsei:codex/sse-headers-upstream
Closed

fix(server): send SSE-friendly headers on /hyper/events#35
jtlocsei wants to merge 1 commit into
dynamic-alpha:mainfrom
jtlocsei:codex/sse-headers-upstream

Conversation

@jtlocsei
Copy link
Copy Markdown
Contributor

Summary

Add SSE-friendly response headers to Hyper's built-in /hyper/events
endpoint:

  • Cache-Control: no-cache, no-transform
  • X-Accel-Buffering: no

Why

Some Hyper deployments sit behind reverse proxies such as NGINX or
OpenResty. Those proxies can buffer or transform text/event-stream
responses, which delays SSE delivery and can leave the browser UI stuck
in transient states even though the server-side action has already
completed.

These headers improved that behaviour in a managed hosting deployment
without requiring app-specific configuration or disabling Brotli.

Notes

  • Cache-Control: no-cache, no-transform is appropriate for a live SSE stream.
  • X-Accel-Buffering: no is useful for NGINX/OpenResty and is generally harmless elsewhere.
  • Content-Type and Content-Encoding remain under Hyper's control.

Testing

Add a focused test covering the initial SSE response headers with and
without Brotli compression.

Prevent reverse proxies such as NGINX and OpenResty from buffering or
transforming Hyper's SSE stream. In some managed hosting setups, that can
delay SSE patches and leave the UI stuck in transient states even though
the underlying action has already completed.

Send Cache-Control: no-cache, no-transform and X-Accel-Buffering: no
with Hyper's built-in /hyper/events response so SSE behaves reliably
behind those proxies while preserving the existing Brotli behavior.
@jtlocsei jtlocsei force-pushed the codex/sse-headers-upstream branch from 83ba40a to 7bdeacc Compare April 18, 2026 03:33
@rschmukler
Copy link
Copy Markdown
Contributor

Merged, thanks!

alekseysotnikov pushed a commit to alekseysotnikov/hyper that referenced this pull request May 4, 2026
Closes dynamic-alpha#35

Prevent reverse proxies such as NGINX and OpenResty from buffering or
transforming Hyper's SSE stream. In some managed hosting setups, that can
delay SSE patches and leave the UI stuck in transient states even though
the underlying action has already completed.

Send Cache-Control: no-cache, no-transform and X-Accel-Buffering: no
with Hyper's built-in /hyper/events response so SSE behaves reliably
behind those proxies while preserving the existing Brotli behavior.

(cherry picked from commit f49074c)

# Conflicts:
#	src/hyper/server.clj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants