Skip to content

Document SSE pauseOnBackground behavior and Last-Event-ID resumption#3681

Open
scriptogre wants to merge 1 commit intobigskysoftware:fourfrom
scriptogre:docs/sse-background-tab-behavior
Open

Document SSE pauseOnBackground behavior and Last-Event-ID resumption#3681
scriptogre wants to merge 1 commit intobigskysoftware:fourfrom
scriptogre:docs/sse-background-tab-behavior

Conversation

@scriptogre
Copy link
Collaborator

Summary

  • Add a "Background Tab Behavior" section to the SSE extension docs explaining that messages are lost while the tab is backgrounded and how servers can use id: fields and Last-Event-ID to replay them
  • Include a FastAPI + sse-starlette example showing a resumable notifications stream
  • Add a test verifying that reconnection after a background pause sends the Last-Event-ID header and that the server can replay missed messages

Context

pauseOnBackground (enabled by default for hx-sse:connect) disconnects the stream when the tab is hidden and reconnects when visible. This exists because iOS Safari silently kills SSE connections when backgrounded without firing error events. The docs didn't explain that messages during the gap are lost or how Last-Event-ID can recover them.

Test plan

  • All existing tests pass (1005 passed, 1 pre-existing alpine-compat failure unrelated to this change)
  • New test verifies the full Last-Event-ID replay flow: connect, receive messages with IDs, background tab, reconnect, server replays missed messages
  • FastAPI example manually tested and working

Add a "Background Tab Behavior" section to the SSE extension docs
explaining that messages are lost while the tab is backgrounded and
how servers can use id: fields and Last-Event-ID to replay them.
Includes a FastAPI + sse-starlette example.

Add a test verifying that reconnection after a background pause sends
the Last-Event-ID header and that the server can replay missed messages.
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.

1 participant