htmx-extensions icon indicating copy to clipboard operation
htmx-extensions copied to clipboard

sse: Close connection before page switch

Open srid opened this issue 1 year ago • 1 comments

Description

This PR may require changes before needing merge. All it does is unconditionally close the SSE connections before the page is about to be switched. The problem is that - on Chrome (but not Safari) if we do not do this, then the SSE connections are kept alive and for every page/route switch, there will be O(n) active SSE connections, which from time to time causes normal link clicks to hang (DevTools shows that request in pending mode) for sometime before the server responds (using Haskell servant here).

Htmx version: https://unpkg.com/[email protected] Used extension(s) version(s): sse from master

Corresponding issue: https://github.com/bigskysoftware/htmx/discussions/2109

I'll leave this as draft just to indicate that a) it is not ready to be merged, b) provide a fork for other interested party to rely upon, and c) maybe inspire somebody else to finish it.

Testing

Checklist

  • [ ] I have read the contribution guidelines
  • [ ] I ran the test suite locally (npm run test) and verified that it succeeded

srid avatar Feb 20 '25 14:02 srid

Deploy Preview for htmx-extensions canceled.

Name Link
Latest commit 0f7b0b569651c259af0fa81d78530f0f540d709b
Latest deploy log https://app.netlify.com/sites/htmx-extensions/deploys/67b741e68395660008ff2087

netlify[bot] avatar Feb 20 '25 14:02 netlify[bot]