bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
38.29k stars 1.31k forks source link

Changing poll interval adds additional poll loops #1350

Closed spiffytech closed 1 year ago

spiffytech commented 1 year ago

When using alpine-morph, if an element begins polling and then changes its poll interval, the existing poll interval is retained, and a new, additional interval is created.

Each time the interval is changed, the browser sends bigger and bigger waves of requests.

If the hx-trigger is removed entirely, all previously-established poll intervals continue. I'm not sure whether this is intentional.

To reproduce, start with this HTML, then make several changes to the every Ns while keeping an eye on the DevTools network tab

<!DOCTYPE html>
<html>
<body>

<div hx-target="this" hx-ext="alpine-morph" hx-swap="morph">
    <div hx-get="/" hx-trigger="every 1s">
        <p>${new Date().toLocaleTimeString()}</p>
    </div>
</div>

<script src="https://unpkg.com/htmx.org@latest"></script>
<script src="https://unpkg.com/htmx.org/dist/ext/alpine-morph.js"></script>
<!-- Alpine Plugins -->
<script defer src="https://unpkg.com/@alpinejs/morph@latest/dist/cdn.min.js"></script>
<!-- Alpine Core -->
<script defer src="https://unpkg.com/alpinejs@latest/dist/cdn.min.js"></script>
</body>
</html>
1cg commented 1 year ago

Bug, will be fixed in the 1.9 release (hopefully this week)