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

  1. Fix the URL/endpoint so the request returns a 2xx status
  2. Check authentication: supply the required API key/token for 401/403 responses
  3. Wrap the fetch chain in try/catch (or .catch) and log response.status for diagnosis
  4. 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

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


AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31). Data as JSON: /api/errors/0d6a2c3dd44143e9. Report an issue: GitHub.