{"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":"Error","httpStatus":null,"severity":"error","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/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts#L787-L823","documentation":"Thrown by createJSCallResult() when the resultType passed from .NET does not match any JSCallResultType enum case (Default=0, JSObjectReference=1, JSStreamReference=2, JSVoidResult=3). This is a defensive default branch; the value is supplied by the .NET runtime when invoking JS, so an unknown value means a version/protocol mismatch between the JS library and the .NET runtime.","triggerScenarios":".NET invokes a JS function with a result type code outside the known enum range (e.g. 4 or higher from a newer runtime loaded against an older JS asset). The switch in createJSCallResult falls through to default and throws.","commonSituations":"JS interop static asset cached (stale) in the browser while the .NET runtime was upgraded to a version using a new result type; mismatched npm package version; custom host emitting an invalid result type code.","solutions":["Hard-refresh / clear cached Microsoft.JSInterop.js assets so the version matches the runtime.","Ensure the npm @microsoft/dotnet-js-interop package version aligns with the SDK version.","If hosting a custom dispatcher, only emit result type codes 0-3."],"exampleFix":"// before (stale cached asset)\n// browser serves old Microsoft.JSInterop.js with new runtime -> unknown resultType\n\n// after\n// clear cache / cache-bust the JS asset so it matches the runtime version\n// e.g. append a version hash to the script src in index.html","handlingStrategy":"validation","validationCode":"// Ensure the served JS interop asset matches the runtime version.\n// <script src=\"_framework/blazor.webassembly.js?v={CACHE_BUSTER}\"></script>\n// and verify window.DotNet.JSCallResultType has the expected enum members.","typeGuard":"function isKnownResultType(t) { return t === 0 || t === 1 || t === 2 || t === 3; }","tryCatchPattern":"try { /* interop invoke */ } catch (e) { if (/Invalid JS call result type/.test(e.message)) { console.error('JS interop asset/runtime version mismatch. Clear cached assets and reload.'); } throw e; }","preventionTips":["Cache-bust or version the Microsoft.JSInterop.js / Blazor boot assets.","Keep the @microsoft/dotnet-js-interop npm package version equal to the SDK version.","Custom dispatchers must only emit result type codes 0-3."],"tags":["js-interop","blazor","serialization","version-mismatch","protocol"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}