sveltejs/kit · error · Error

response.status is not a number. value: "${response.status}"

Error message

response.status is not a number. value: "${response.status}" type: ${typeof response.status}

What it means

SvelteKit caches fetched resources during load and stores the HTTP status as a number. `push_fetched` converts `response.status` with `Number()` and throws if the result is NaN, meaning the status is not a usable numeric value — indicating a malformed/mock response object was passed through the fetch instrumentation.

Source

Thrown at packages/kit/src/runtime/server/page/load_data.js:325

						} 'Access-Control-Allow-Origin' header is present on the requested resource`
					);
				}
			}
		}

		/** @type {ReadableStream<Uint8Array>} */
		let teed_body;

		const proxy = new Proxy(response, {
			get(response, key, receiver) {
				/**
				 * @param {string | undefined} body
				 * @param {boolean} is_b64
				 */
				async function push_fetched(body, is_b64) {
					const status_number = Number(response.status);
					if (isNaN(status_number)) {
						throw new Error(
							`response.status is not a number. value: "${
								response.status
							}" type: ${typeof response.status}`
						);
					}

					const request_body =
						input instanceof Request && cloned_body
							? await new Response(cloned_body).text()
							: init?.body;

					if (
						request_body &&
						typeof request_body !== 'string' &&
						!ArrayBuffer.isView(request_body)
					) {
						// requests whose body can't be hashed aren't serialized — the browser repeats the fetch
						return;

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Fix the mock/wrapper so `status` is a number (use the real `Response` class: `new Response(body, { status: 200 })`)
  2. If wrapping fetch, ensure the returned object is a genuine `Response` instance
  3. Search for code assigning `status` as a string and coerce with `Number()`

Example fix

// before (bad mock)
global.fetch = async () => ({ status: '200', json: async () => data });
// after
global.fetch = async () => new Response(JSON.stringify(data), { status: 200, headers: { 'content-type': 'application/json' } });
Defensive patterns

Strategy: type-guard

Validate before calling

function hasNumericStatus(obj) {
  return typeof obj?.status === 'number' && Number.isFinite(obj.status);
}
if (!hasNumericStatus(mockResponse)) throw new TypeError('mock must return numeric status');

Type guard

/** @returns {r is Response} */
function isRealResponse(r) {
  return r instanceof Response && typeof r.status === 'number';
}

Prevention

When it happens

Trigger: A mocked or polyfilled `fetch` returning a Response-like object whose `status` is a string like `"OK"`, `undefined`, or otherwise non-numeric, used inside a load function where SvelteKit records dependencies.

Common situations: Unit-test mocks of global fetch that don't produce a real `Response` (e.g. `{ json: () => ... }` plain objects); custom fetch wrappers or service-worker shims with wrong status fields; misconfigured MSW handlers.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/edaac6549ab6e1c5. Report an issue: GitHub.