{"record":{"id":"8bef133e27e56f59","repo":"dotnet/aspnetcore","slug":"invalid-js-call-result-type-resulttype","errorCode":null,"errorMessage":"Invalid JS call result type '${resultType}'.","messagePattern":"Invalid JS call result type '(.+?)'\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts","lineNumber":805,"sourceCode":"          this.streamPromise = new Promise((resolve, reject) => {\n              this.resolve = resolve;\n              this.reject = reject;\n          });\n      }\n  }\n\n  function createJSCallResult(returnValue: any, resultType: JSCallResultType) {\n      switch (resultType) {\n      case JSCallResultType.Default:\n          return returnValue;\n      case JSCallResultType.JSObjectReference:\n          return createJSObjectReference(returnValue);\n      case JSCallResultType.JSStreamReference:\n          return createJSStreamReference(returnValue);\n      case JSCallResultType.JSVoidResult:\n          return null;\n      default:\n          throw new Error(`Invalid JS call result type '${resultType}'.`);\n      }\n  }\n\n  let nextByteArrayIndex = 0;\n  function stringifyArgs(callDispatcher: CallDispatcher, args: any[] | null) {\n      nextByteArrayIndex = 0;\n      currentCallDispatcher = callDispatcher;\n      const result = JSON.stringify(args, argReplacer);\n      currentCallDispatcher = undefined;\n      return result;\n  }\n\n  function getCaptureIdFromElement(element: Element): string | null {\n      for (let i = 0; i < element.attributes.length; i++) {\n          const attr = element.attributes[i];\n          if (attr.name.startsWith(\"_bl_\")) {\n              return attr.name.substring(4);\n          }","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts#L787-L823","documentation":"Thrown by createJSCallResult in its default branch. The switch over JSCallResultType covers Default, JSObjectReference, JSStreamReference, JSVoidResult; reaching default means the framework received a numeric resultType outside the enum's defined range. This is an internal contract violation: the resultType is chosen by the framework plumbing based on the .NET return-type hint, not by user code.","triggerScenarios":"A version skew between the .NET runtime and the JS interop bundle where new/renamed JSCallResultType values are sent; a corrupted/truncated payload flipping the resultType bits; a custom interop host emitting an unknown resultType. App code cannot normally pass an arbitrary value here.","commonSituations":"Mixing a newer server runtime with an older Microsoft.JSInterop.js bundle (or vice versa); a misbehaving custom transport; bit-flips in long-running stress.","solutions":["Ensure the JS interop bundle and the .NET runtime are the same version (update both NuGet and the JS package).","If using a custom transport, verify it forwards the exact JSCallResultType enum value.","Clear the browser cache / service-worker cache to drop a stale JS bundle.","Report as a framework bug if it reproduces with matched versions."],"exampleFix":"// before\n// server runtime 8.0.2 + cached JS bundle 7.0.5 -> unknown resultType\n\n// after\n// bump JS interop package to match runtime, force cache-bust\n// <script src=\"_framework/blazor.web.js?v=8.0.2\"></script>","handlingStrategy":"try-catch","validationCode":"// verify version match before trusting results\nconst runtimeVer = await JS.InvokeAsync<string>('__getRuntimeVersion');\nif (runtimeVer !== EXPECTED_JS_VER) throw new Error('JS/.NET version mismatch');","typeGuard":"null","tryCatchPattern":"try { await JS.InvokeAsync<object>('fn'); } catch (e) { if (/Invalid JS call result type/i.test(e.message)) { location.reload(true); } else throw e; }","preventionTips":["Keep the JS interop bundle and .NET runtime on the same version.","Bust browser/service-worker caches of the JS bundle after upgrades.","Treat this error as fatal and force a reload/reconnect."],"tags":["blazor","jsinterop","internal","version-mismatch","corruption"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}