Skip to content

Fix: check HTTP status in history.js fetch calls (#6282)#7016

Draft
JackieLin999 wants to merge 1 commit intoopenstreetmap:masterfrom
JackieLin999:fix/history-fetch-error-handling
Draft

Fix: check HTTP status in history.js fetch calls (#6282)#7016
JackieLin999 wants to merge 1 commit intoopenstreetmap:masterfrom
JackieLin999:fix/history-fetch-error-handling

Conversation

@JackieLin999
Copy link
Copy Markdown

Fixes #6282

Added HTTP status checking to the fetch calls in loadFirstChangesets
and loadMoreChangesets so that error responses (e.g. 504 gateway timeout)
are handled gracefully instead of being rendered as HTML in the history panel.

@tomhughes
Copy link
Copy Markdown
Member

That's an awful lot of code just to check for load errors - was an AI perhaps involved in writing this?

I see there's also a lot of HTML being generated in javascript which we prefer to avoid where we can.

setListFetchData(data, url);

fetch(url.pathname + "?" + data)
.then(response => response.text())
Copy link
Copy Markdown
Collaborator

@HolgerJeromin HolgerJeromin Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here a short path would be

.then(response => {
    if(!response.ok) {
        throw new Error("Request failed. Got http code: " + response.status + " " + response.statusText);
    }
    return response.text();
})

and a slim catch handler.

@hlfan hlfan marked this pull request as draft April 20, 2026 19:47
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.

History: Gateway timeout error does not display properly

3 participants