MagicMirrorOrg/MagicMirror · error · Error
response.statusText
Error message
response.statusText
What it means
NodeHelper.checkFetchStatus is a fetch response filter: if response.ok is false (HTTP status outside 200-299) it throws an Error whose message is response.statusText. Because it uses statusText (which may be an empty string in HTTP/2 or Node fetch), the thrown error can be uninformative; the status code itself is not included.
Source
Thrown at js/node_helper.js:139
}
} else {
this.socketNotificationReceived(notification, payload);
}
});
});
}
/**
* Check the status of a fetch response.
* @param {Response} response The fetch response.
* @returns {Response} The fetch response if ok.
*/
static checkFetchStatus (response) {
// response.status >= 200 && response.status < 300
if (response.ok) {
return response;
} else {
throw Error(response.statusText);
}
}
/**
* Look at the specified error and return an appropriate error type, that
* can be translated to a detailed error message
* @param {Error} error the error from fetching something
* @returns {string} the string of the detailed error message in the translations
*/
static checkFetchError (error) {
let error_type = "MODULE_ERROR_UNSPECIFIED";
if (error.code === "EAI_AGAIN") {
error_type = "MODULE_ERROR_NO_CONNECTION";
} else {
const message = typeof error.message === "string" ? error.message.toLowerCase() : "";
if (message.includes("unauthorized") || message.includes("http 401") || message.includes("http 403")) {
error_type = "MODULE_ERROR_UNAUTHORIZED";
}View on GitHub (pinned to 4b4a59534f)
Solutions
- Fix the URL/endpoint so the request returns a 2xx status
- Check authentication: supply the required API key/token for 401/403 responses
- Wrap the fetch chain in try/catch (or .catch) and log response.status for diagnosis
- Prefer logging status and statusText explicitly instead of relying on statusText alone
Example fix
// before
const res = await fetch(url).then(NodeHelper.checkFetchStatus);
// after
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
return res; Defensive patterns
Strategy: try-catch
Validate before calling
const res = await fetch(url);
if (!res.ok) {
throw new Error(`Request failed with HTTP status ${res.status}`);
} Type guard
function isOkResponse(res) {
return typeof res === "object" && res !== null && res.ok === true;
} Try / catch
try {
const res = await fetch(url).then(NodeHelper.checkFetchStatus);
// use res
} catch (err) {
Log.error(`Fetch failed: ${err.message || "non-2xx response (empty statusText)"}`);
} Prevention
- Never rely on statusText alone; it is often empty in HTTP/2 and Node fetch
- Log res.status explicitly when a fetch fails
- Check API keys and endpoint URLs when seeing 401/403/404 errors
- Handle 429 rate limits with backoff
When it happens
Trigger: Any fetch().then(NodeHelper.checkFetchStatus) chain where the server responds with a non-2xx status: 404 for a wrong URL, 401/403 for missing credentials, 500 for server errors, 429 rate limiting.
Common situations: Modules fetching remote APIs that changed endpoints; missing API keys causing 401; typos in URLs giving 404; servers returning empty statusText (Node fetch/HTTP2) so the error message is blank.
Related errors
- HTTP ${response.status}
- Invalid API response
- Failed to fetch grid point: HTTP ${pointsResponse.status}
- Invalid grid point data
- Failed to fetch observation stations: HTTP ${stationsRespons
AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31).
Data as JSON: /api/errors/0d6a2c3dd44143e9.
Report an issue: GitHub.