{"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/60108ba66eb7d1d12f595480091b4ad80a24b172/src/native/libs/System.Native.Browser/native/index.ts#L7-L43","documentation":"The Native module (System.Native.Browser/native) verifies during dotnetInitializeModule() that the loader-supplied runtimeBuildInfo.gitHash matches _ems_.DOTNET.gitHash (the hash baked into the core runtime bundle). A mismatch means the native-browser support JS was built from a different commit than the core .NET runtime.","triggerScenarios":"dotnet.runtime.js (DOTNET bundle) and the System.Native native-support JS come from different builds; _ems_.DOTNET.gitHash is populated but differs from the loader-reported hash.","commonSituations":"Stale cached dotnet.*.js while the .wasm/runtime JS is refreshed; hand-assembled wwwroot mixing files from SDK versions; partial publish; dev workflow that rebuilds only one project.","solutions":["Publish/copy the entire _framework (or equivalent) folder from one consistent build so all dotnet JS bundles share a git hash.","Clear browser/CDN/proxy caches that may serve a mix of old and new JS.","Rebuild from clean (rm -rf bin obj) to guarantee the workload stamps a single hash across all support modules.","Verify the deployed dotnet.runtime.js, the native support JS, and the WASM all carry the same version metadata."],"exampleFix":"// before: dotnet.runtime.js from SDK 8.0.x, System.Native support JS from 9.0.x\n\n// after: single consistent workload publish\n// dotnet workload restore\n// dotnet publish -c Release  (copy whole _framework output)","handlingStrategy":"validation","validationCode":"// Verify all support modules share the runtime's git hash before initializing.\nfunction assertConsistentBuild(runtimeApi: any, nativeHash: string) {\n  const loader = runtimeApi?.runtimeBuildInfo?.gitHash;\n  if (loader && loader !== nativeHash) {\n    throw new Error(`Build mismatch: loader=${loader} native=${nativeHash}. Redeploy consistently.`);\n  }\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Deploy the full _framework from one publish; never mix SDK versions.","Cache-bust and fingerprint JS bundles to prevent stale-asset mixing.","Clean (rm -rf bin obj) before building to guarantee a single stamped hash.","Verify the hash reported by each module post-deploy."],"tags":["git-hash","build-integrity","native","version-mismatch"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}