{"record":{"id":"edaac6549ab6e1c5","repo":"sveltejs/kit","slug":"response-status-is-not-a-number-value-respons","errorCode":null,"errorMessage":"response.status is not a number. value: \"${response.status}\" type: ${typeof response.status}","messagePattern":"response\\.status is not a number\\. value: \"(.+?)\" type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/server/page/load_data.js","lineNumber":325,"sourceCode":"\t\t\t\t\t\t} 'Access-Control-Allow-Origin' header is present on the requested resource`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/** @type {ReadableStream<Uint8Array>} */\n\t\tlet teed_body;\n\n\t\tconst proxy = new Proxy(response, {\n\t\t\tget(response, key, receiver) {\n\t\t\t\t/**\n\t\t\t\t * @param {string | undefined} body\n\t\t\t\t * @param {boolean} is_b64\n\t\t\t\t */\n\t\t\t\tasync function push_fetched(body, is_b64) {\n\t\t\t\t\tconst status_number = Number(response.status);\n\t\t\t\t\tif (isNaN(status_number)) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`response.status is not a number. value: \"${\n\t\t\t\t\t\t\t\tresponse.status\n\t\t\t\t\t\t\t}\" type: ${typeof response.status}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst request_body =\n\t\t\t\t\t\tinput instanceof Request && cloned_body\n\t\t\t\t\t\t\t? await new Response(cloned_body).text()\n\t\t\t\t\t\t\t: init?.body;\n\n\t\t\t\t\tif (\n\t\t\t\t\t\trequest_body &&\n\t\t\t\t\t\ttypeof request_body !== 'string' &&\n\t\t\t\t\t\t!ArrayBuffer.isView(request_body)\n\t\t\t\t\t) {\n\t\t\t\t\t\t// requests whose body can't be hashed aren't serialized — the browser repeats the fetch\n\t\t\t\t\t\treturn;","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/server/page/load_data.js#L307-L343","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Fix the mock/wrapper so `status` is a number (use the real `Response` class: `new Response(body, { status: 200 })`)","If wrapping fetch, ensure the returned object is a genuine `Response` instance","Search for code assigning `status` as a string and coerce with `Number()`"],"exampleFix":"// before (bad mock)\nglobal.fetch = async () => ({ status: '200', json: async () => data });\n// after\nglobal.fetch = async () => new Response(JSON.stringify(data), { status: 200, headers: { 'content-type': 'application/json' } });","handlingStrategy":"type-guard","validationCode":"function hasNumericStatus(obj) {\n  return typeof obj?.status === 'number' && Number.isFinite(obj.status);\n}\nif (!hasNumericStatus(mockResponse)) throw new TypeError('mock must return numeric status');","typeGuard":"/** @returns {r is Response} */\nfunction isRealResponse(r) {\n  return r instanceof Response && typeof r.status === 'number';\n}","tryCatchPattern":null,"preventionTips":["In tests, mock with the real Response class instead of plain objects","Never string-coerce status codes in fetch wrappers","Verify MSW/handlers return valid Response instances"],"tags":["fetch","mocking","sveltekit","response-status"],"backgroundTag":"invalid-response-status","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}