{"record":{"id":"958fd14b95b7b535","repo":"denoland/deno","slug":"invalid-response","errorCode":null,"errorMessage":"Invalid response","messagePattern":"Invalid response","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/http/00_serve.ts","lineNumber":532,"sourceCode":"      op_http_set_response_body_static_with_default_header(req, body, status);\n      return true;\n    case SERVE_FAST_HEADER_CONTENT_TYPE:\n      op_http_set_response_body_static_with_content_type(\n        req,\n        body,\n        status,\n        response[serveFastContentTypeKey],\n      );\n      return true;\n    case SERVE_FAST_HEADER_NONE:\n      if (typeof body === \"string\") {\n        op_http_set_response_body_text(req, body, status);\n      } else {\n        op_http_set_response_body_bytes(req, body, status);\n      }\n      return true;\n    default:\n      throw new TypeError(\"Invalid response\");\n  }\n}\n\n// Report an error that was thrown while a streaming response body was being\n// drained. The response status/headers are already on the wire at this point,\n// so the value returned from `onError` can no longer be used; we route the\n// error through the handler purely so it is observed (the default handler logs\n// a stack trace) instead of being silently swallowed.\nfunction reportResponseStreamError(onError, error) {\n  let result;\n  try {\n    result = onError(error);\n  } catch (e) {\n    internals.log(\"error\", \"Exception in onError while handling exception\", e);\n    return;\n  }\n  if (ObjectPrototypeIsPrototypeOf(PromisePrototype, result)) {\n    PromisePrototypeThen(result, undefined, (e) => {","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/http/00_serve.ts#L514-L550","documentation":"trySetServeFastStaticResponse is an internal fast path used when a handler returns a response carrying Deno's private serveFast* symbol marks (set by optimized Response creation paths). It switches on an internal header-kind tag, and the default branch throws 'Invalid response' when that tag holds a value outside the known SERVE_FAST_HEADER_* enum. Standard user code cannot reach this state through public APIs; it signals an internal invariant break.","triggerScenarios":"Code that manually writes Deno internal symbols (Deno[Deno.internal], serveFastStatusKey/serveFastHeaderKindKey) onto an object with an invalid header-kind value, or a regression inside Deno's optimized Response path itself.","commonSituations":"Experiments or monkey-patching that touch Deno.internal, or hitting a Deno bug in an unreleased/nightly build's fast-response optimization.","solutions":["Remove code that manipulates Deno internal symbols and return plain Response objects","Update to the latest Deno patch release in case the fast-path tagging was fixed","As a stopgap, rebuild the response before returning it: new Response(body, response) so no fast marks are present","If it reproduces with public APIs only, file a minimal repro at github.com/denoland/deno"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Wrap the whole request path; this error indicates an internal invariant break\nDeno.serve(async (req) => {\n  try {\n    return await handler(req);\n  } catch (err) {\n    return new Response(\"Internal Server Error\", { status: 500 });\n  }\n});","preventionTips":["Never write or read Deno internal symbols (Deno[Deno.internal], serveFast* keys)","Return responses built from public constructors only","Pin a stable Deno release in CI to avoid nightly fast-path regressions"],"tags":["http","serve","internal","invariant","fast-path"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}