{"record":{"id":"eb46b2ac7d985a08","repo":"dotnet/runtime","slug":"mismatched-git-hashes-between-loader-and-runtime","errorCode":null,"errorMessage":"Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, BrowserHost: ${GitHash}","messagePattern":"Mismatched git hashes between loader and runtime\\. Loader: (.+?), BrowserHost: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/Common/JavaScript/host/index.ts","lineNumber":22,"sourceCode":"import type { InternalExchange, BrowserHostExports, RuntimeAPI, BrowserHostExportsTable, LoaderConfigInternal } from \"./types\";\nimport { InternalExchangeIndex } from \"./types\";\nimport { _ems_ } from \"../ems-ambient\";\n\nimport GitHash from \"consts:gitHash\";\n\nimport { runMain, runMainAndExit, initializeCoreCLR } from \"./host\";\nimport { registerPdbBytes, instantiateWebcilModule, registerDllBytes, installVfsFile, loadIcuData, instantiateWasm, } from \"./assets\";\n\nexport function dotnetInitializeModule(internals: InternalExchange): void {\n    if (!Array.isArray(internals)) throw new Error(\"Expected internals to be an array\");\n    const runtimeApiLocal: Partial<RuntimeAPI> = {\n        runMain,\n        runMainAndExit,\n    };\n    const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];\n    if (typeof runtimeApi !== \"object\") throw new Error(\"Expected internals to have RuntimeAPI\");\n    if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== GitHash) {\n        throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, BrowserHost: ${GitHash}`);\n    }\n    Object.assign(runtimeApi, runtimeApiLocal);\n\n    internals[InternalExchangeIndex.BrowserHostExportsTable] = browserHostExportsToTable({\n        registerDllBytes,\n        installVfsFile,\n        loadIcuData,\n        initializeCoreCLR,\n        registerPdbBytes,\n        instantiateWasm,\n        instantiateWebcilModule,\n    });\n    _ems_.dotnetUpdateInternals(internals, _ems_.dotnetUpdateInternalsSubscriber);\n\n    setupEmscripten();\n\n    function browserHostExportsToTable(map: BrowserHostExports): BrowserHostExportsTable {\n        // keep in sync with browserHostExportsFromTable()","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/Common/JavaScript/host/index.ts#L4-L40","documentation":"Thrown by dotnetInitializeModule (BrowserHost) when the runtime reports a git hash that differs from the GitHash compiled into the BrowserHost module. The .NET WASM runtime requires loader JS, BrowserHost JS, and the native binary to originate from the same build; a mismatch indicates mixed versions.","triggerScenarios":"dotnetInitializeModule(internals) where internals[RuntimeAPI].runtimeBuildInfo.gitHash is non-empty and !== the BrowserHost's bundled GitHash constant.","commonSituations":"Browser cached an old dotnet.runtime.js / dotnet.native.js while fetching a freshly deployed dotnet.native.wasm; CDN partial rollout; mixing SDK/workload versions manually; hot-reload serving stale runtime chunks.","solutions":["Hard-refresh / clear the browser cache (or disable cache during dev) so all runtime assets reload together.","Serve runtime assets with cache-busting versioned URLs or query strings.","Purge the CDN atomically for all framework files on each deploy.","Reinstall/republish a single consistent .NET workload/SDK version for both loader and runtime outputs."],"exampleFix":"// before: unversioned runtime assets get stale-cached\n<script src=\"_framework/dotnet.native.js\"></script>\n// after: cache-bust on deploy\n<script src=\"_framework/dotnet.native.js?v=20260806a\"></script>","handlingStrategy":"validation","validationCode":"// Before initializing, confirm loader and runtime share a git hash\nimport runtimeGitHash from 'consts:gitHash'; // loader-side\nconst api = internals[InternalExchangeIndex.RuntimeAPI];\nif (api?.runtimeBuildInfo?.gitHash && api.runtimeBuildInfo.gitHash !== runtimeGitHash) {\n  throw new Error(`Version skew detected; reload all framework assets (loader ${runtimeGitHash} vs runtime ${api.runtimeBuildInfo.gitHash}).`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Version all framework asset URLs so a new deploy invalidates old caches.","Hard-refresh during upgrades when you see version-mismatch symptoms.","Purge CDN entries for every framework file together, never partially."],"tags":["version-mismatch","cache","deployment","initialization"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}