Skip to content

docs: warn that backgrounded SSE tabs drop events and document resync#1978

Merged
davidpoblador merged 1 commit into
mainfrom
worktree-docs-sse-pauseonbackground-1976
Jun 2, 2026
Merged

docs: warn that backgrounded SSE tabs drop events and document resync#1978
davidpoblador merged 1 commit into
mainfrom
worktree-docs-sse-pauseonbackground-1976

Conversation

@davidpoblador

Copy link
Copy Markdown
Member

Closes #1976.

Problem

hx-sse:connect in htmx v4 enables pauseOnBackground by default: when a tab
is hidden the extension closes the stream, and sse_endpoint(...) has no replay
without buffer_size. Any broadcast() sent during the hidden window is lost
permanently, so live views silently go stale until the next event or a manual
reload. Nothing in the docs flagged this, and the existing SSE client examples
used sse-connect/sse-swap, which htmx v4 has deprecated (sse-connect)
and removed (sse-swap).

What changed (docs only)

  • development-guide.md — rewrote the HTMX Integration section to the htmx 4
    model (named events → DOM triggers consumed via hx-trigger; unnamed messages
    auto-swap). Added a "Backgrounded Tabs Drop Events — Resync on Reconnect"
    section with the pauseOnBackground warning, the resync pattern
    (htmx:after:sse:connection trigger re-fetches current state on every
    reconnect), the hx-config="sse.pauseOnBackground:false" knob, and a
    buffer_size multi-worker caveat (per-process monotonic IDs can't replay
    reliably across workers).
  • htmx-migration.md — corrected the SSE migration section, which wrongly
    claimed sse-connect/sse-swap "work exactly the same" in v4; documented that
    sse-swap is removed and there is no hx-sse:swap; added the backgrounding
    warning; fixed the troubleshooting note and a dead upstream link.
  • background-tasks.md — updated the upload-progress example to the v4
    unnamed-message auto-swap model and cross-linked the resync guidance.
  • llms-full.txt — mirrored the client example and migration fixes with a
    concise warning.
  • vibetuner-js/README.md and vibetuner-template/.claude/rules/frontend.md
    — fixed the remaining deprecated sse-connect/sse-swap snippets.

Verification

  • Confirmed every claim against the bundled htmx 4.0.0-beta4 hx-sse.js
    (pauseOnBackground: isConnect, reader.cancel() on visibilitychange,
    named→htmx.trigger, unnamed→htmx.swap, htmx:after:sse:connection on every
    reconnect, sse-swap removal warning) and against the upstream htmx 4 SSE docs.
  • rumdl passes on all touched markdown files (via pre-commit).

🤖 Generated with Claude Code

htmx v4's hx-sse:connect enables pauseOnBackground by default, closing the
stream while a tab is hidden with no replay, so events broadcast during the
hidden window are lost and live views silently go stale (issue #1976).

Document the resync-on-reconnect pattern (re-fetch current state on
htmx:after:sse:connection), the pauseOnBackground knob, and the per-process
buffer_size multi-worker caveat.

Also correct the SSE client examples for the htmx 4 model: sse-connect ->
hx-sse:connect, and sse-swap is removed (named events dispatch as DOM
triggers; unnamed messages auto-swap), across the development guide, htmx
migration guide, background-tasks guide, llms-full.txt, the JS README, and
the scaffolded template frontend rules.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@davidpoblador davidpoblador merged commit 6bb1a91 into main Jun 2, 2026
2 checks passed
@davidpoblador davidpoblador deleted the worktree-docs-sse-pauseonbackground-1976 branch June 2, 2026 17:04
davidpoblador pushed a commit that referenced this pull request Jun 2, 2026
🤖 I have created a release *beep* *boop*
---


##
[10.22.4](v10.22.3...v10.22.4)
(2026-06-02)


### Bug Fixes

* fast-path worker-health to skip CLI bootstrap
([#1974](#1974))
([#1977](#1977))
([ee77f6c](ee77f6c))
* load ProjectConfiguration deploy-config from .env
([#1970](#1970))
([#1971](#1971))
([13b67a7](13b67a7))
* negotiate Accept-Language with language-only subtag fallback
([#1973](#1973))
([#1975](#1975))
([0738181](0738181))


### Documentation Updates

* warn that backgrounded SSE tabs drop events and document resync
([#1978](#1978))
([6bb1a91](6bb1a91))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

SSE: pauseOnBackground silently drops events with no resync, so backgrounded tabs go stale

1 participant