windmill-labs/windmill · error
HTTP ${response.status}
Error message
HTTP ${response.status} What it means
resetSlowStats in DbHealth.svelte POSTs to /api/db_health/slow_queries/reset and throws 'HTTP <status>' when the server responds with a non-2xx status AND an empty body. The response body text is preferred as the error message; the HTTP status fallback only appears when the backend returns no body.
Source
Thrown at frontend/src/lib/components/instanceSettings/DbHealth.svelte:34
let slowSort: SlowQuerySort = $state('total')
let slowSortLoading = $state(false)
let expandedQueries: Record<number, boolean> = $state({})
async function resetSlowStats() {
if (
!confirm(
'Reset pg_stat_statements? This clears cumulative stats for ALL queries on this postgres instance.'
)
)
return
try {
const response = await fetch(`/api/db_health/slow_queries/reset`, {
method: 'POST',
credentials: 'include'
})
if (!response.ok) {
const text = await response.text()
throw new Error(text || `HTTP ${response.status}`)
}
// refetch with current sort
const refetch = await fetch(`/api/db_health/slow_queries?sort=${slowSort}`, {
credentials: 'include'
})
if (refetch.ok && data) {
data.slow_queries = await refetch.json()
expandedQueries = {}
}
sendUserToast('pg_stat_statements reset successfully', false)
} catch (e: any) {
sendUserToast('Failed to reset stats: ' + e.message, true)
}
}
async function setSlowSort(sort: SlowQuerySort) {
if (sort === slowSort || slowSortLoading) return
slowSort = sortView on GitHub (pinned to e474e8803c)
Solutions
- Check the browser network tab for the actual HTTP status of /api/db_health/slow_queries/reset
- Log in again as an admin user if the status is 401/403
- Verify the backend version supports the db_health endpoints (404 means the route does not exist)
- Check backend logs for a 5xx trace if the server errored with an empty body
Defensive patterns
Strategy: try-catch
Validate before calling
const session = await getSession()
if (!session || !isAdmin(session)) { showLoginPrompt(); return } Type guard
function isOk(r: Response): r is Response & { ok: true } { return r.ok } Try / catch
try {
await resetSlowStats()
} catch (e) {
sendUserToast('Could not reset slow query stats: ' + e.message, true)
if (e.message === 'HTTP 401' || e.message === 'HTTP 403') reAuth()
} Prevention
- Only expose/use this action as an instance admin
- Handle session expiry by re-authenticating on 401
- Confirm the backend version includes /api/db_health/slow_queries/reset
- Check backend logs when the error message is a bare 'HTTP 5xx' (empty body)
When it happens
Trigger: Calling resetSlowStats() when the reset endpoint returns an error status with an empty response body — e.g. 401/403 (not admin or expired session), 404/405 (endpoint unavailable in this build/version), or 500 with empty body.
Common situations: Non-admin user opening the instance-settings DB health page (endpoint requires admin); session token expired; running an older backend without the db_health endpoints (404).
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- GET ${path} -> ${resp.status}
- ${text}
- inline_checkpoint API ${resp.status}
- res.statusText
- Variable not found at ${path} or not visible to you: ${e.bod
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/6507e42570ca7150.
Report an issue: GitHub.