Skip to content

HTMX 4 hx-sse:connect gets stuck while trying to reconnect when server is down #4072

Description

@taai

I'm using HTMX 4.0.0 and hx-sse, I'm testing the "persistent connections".

The reconnect works. But only if the backend server is turned on. If I shut down the back-end server, the hx-sse tries to reconnect and gets stuck in a pending state. I started the back-end server, but the hx-sse did nothing. Is there a timeout option to cancel the request and try again...? I suspect that it gets stuck because there is no timeout on creating a connection.

Tried Firefox and Chromium. Backend server was on my local computer.

I did everything per documentation, also tried configuration settings.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <meta name="htmx-config" content="sse.reconnect:true sse.pauseOnBackground:false">
    <script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/htmx.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/htmx.org@4.0.0/dist/ext/hx-sse.min.js"></script>
</head>
<body>
    <div hx-sse:connect="/events"></div>
</body>
</html>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions