bigskysoftware / bigskysoftware/htmx

No error handler for history cache miss and send error

Open
#3,192 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

When a cache miss occurs, htmx will fetch content from the server. If the server replies with an >=200 && <400 status, then `htmx:historyCacheMissLoadError` fires. This works as expected.

However when I shutdown my server and initiate a cache miss fetch, no events are triggered (I checked `htmx.logAll()`). When the server is shutdown and a request is made then `htmx:sendError` gets triggered. I am expecting some similar event during cache miss to be fired.

It seems `loadHistoryFromServer` [creates a new XHR](https://github.com/bigskysoftware/htmx/blob/v2.0.4/src/htmx.js#L3227) without the helper function `issueAjaxRequest` that adds a `xhr.onerror` [callback](https://github.com/bigskysoftware/htmx/blob/v2.0.4/src/htmx.js#L4497).

Side note: the [docs](https://htmx.org/events/#htmx:historyCacheMissError) say `htmx:historyCacheMissError` not htmx:historyCacheMissLoadError`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.