{"record":{"id":"53a4f0abbfd8301b","repo":"dotnet/runtime","slug":"mismatched-git-hashes-between-loader-and-runtime-53a4f0","errorCode":null,"errorMessage":"Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, DOTNET: ${_ems_.DOTNET.gitHash}","messagePattern":"Mismatched git hashes between loader and runtime\\. Loader: (.+?), DOTNET: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/native/libs/System.Native.Browser/native/index.ts","lineNumber":25,"sourceCode":"import { _ems_ } from \"../../Common/JavaScript/ems-ambient\";\nimport GitHash from \"consts:gitHash\";\n\nexport { SystemJS_RandomBytes } from \"./crypto\";\nexport { SystemJS_GetLocaleInfo } from \"./globalization-locale\";\nexport { SystemJS_RejectMainPromise, SystemJS_ResolveMainPromise, SystemJS_MarkAsyncMain, SystemJS_ConsoleClear } from \"./main\";\nexport { SystemJS_ScheduleTimer, SystemJS_ScheduleBackgroundJob, SystemJS_ScheduleFinalization, SystemJS_ScheduleDiagnosticServer } from \"./scheduling\";\nexport { ds_rt_websocket_close, ds_rt_websocket_create, ds_rt_websocket_poll, ds_rt_websocket_recv, ds_rt_websocket_send, ds_rt_browser_performance_measure } from \"./diagnostics\";\n\n\nexport const gitHash = GitHash;\nexport function dotnetInitializeModule(internals: InternalExchange): void {\n    if (!Array.isArray(internals)) throw new Error(\"Expected internals to be an array\");\n\n    const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];\n    if (typeof runtimeApi !== \"object\") throw new Error(\"Expected internals to have RuntimeAPI\");\n\n    if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== _ems_.DOTNET.gitHash) {\n        throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, DOTNET: ${_ems_.DOTNET.gitHash}`);\n    }\n\n    internals[InternalExchangeIndex.NativeBrowserExportsTable] = nativeBrowserExportsToTable({\n        getWasmMemory,\n        getWasmTable,\n        SystemJS_ScheduleDiagnosticServer: _ems_._SystemJS_ScheduleDiagnosticServer,\n        SystemJS_GetMethodName: (pMethodDesc: number) => _ems_._SystemJS_GetMethodName(pMethodDesc),\n    });\n    _ems_.dotnetUpdateInternals(internals, _ems_.dotnetUpdateInternalsSubscriber);\n\n    setupEmscripten();\n\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    function nativeBrowserExportsToTable(map: NativeBrowserExports): NativeBrowserExportsTable {\n        // keep in sync with nativeBrowserExportsFromTable()\n        return [\n            map.getWasmMemory,\n            map.getWasmTable,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/System.Native.Browser/native/index.ts#L7-L43","documentation":"The native module compares the loader's runtimeBuildInfo.gitHash against _ems_.DOTNET.gitHash baked into the runtime/WASM build. A mismatch means the JS loader and the native/runtime binaries were built from different source revisions, which would silently break the native↔JS ABI, so initialization refuses to continue.","triggerScenarios":"Loading a dotnet.native.js/loader from one commit together with a dotnet.wasm/runtime (DOTNET) from a different commit, so the two git hashes disagree.","commonSituations":"Partial deploy; CDN/browser cache serving a mix of old and new dotnet files; local dev with uncommitted cross-repo builds; hand-editing bootconfig to point at mismatched runtime versions.","solutions":["Do a clean rebuild + republish so every dotnet.* artifact (loader, native, wasm, runtime) is from the same commit/SDK.","Hard-refresh the browser, purge the CDN, and unregister any service worker to drop cached bundles.","Pin all dotnet files to the exact same version string in one versioned folder so caches can't mix them."],"exampleFix":"// before: mixed CDN/runtime versions\n<script src=\"https://cdn/7.0.0/dotnet.js\"></script>\n<!-- bootconfig referencing 8.0.0 runtime/wasm -->\n\n// after: all artifacts from the same 8.0.x build\n<script src=\"https://cdn/8.0.x/dotnet.js\"></script>","handlingStrategy":"validation","validationCode":"const loaderHash = runtimeApi.runtimeBuildInfo?.gitHash;\nif (loaderHash && loaderHash !== _ems_.DOTNET.gitHash) {\n  throw new Error(\"Refusing init: loader/runtime git hash mismatch — republish with a matching build\");\n}","typeGuard":null,"tryCatchPattern":"try { dotnetInitializeModule(internals); }\ncatch (e) {\n  if (/Mismatched git hashes/.test(e.message)) location.reload(true); // after cache purge\n  else throw e;\n}","preventionTips":["Cache-bust all dotnet bundles together (versioned folder or content hash in URL).","Never hand-edit bootconfig to point at different runtime versions.","Validate git-hash agreement before init in custom hosts."],"tags":["version-mismatch","build","deployment"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}