{"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":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","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/60108ba66eb7d1d12f595480091b4ad80a24b172/src/native/libs/Common/JavaScript/host/index.ts#L4-L40","documentation":"Thrown by dotnetInitializeModule() (src/native/libs/Common/JavaScript/host/index.ts:13). The BrowserHost module is compiled with consts:gitHash, and the loader hands its own runtimeBuildInfo.gitHash in the InternalExchange. If both are non-empty and differ, the host refuses to wire exports because a loader/runtime build mismatch can corrupt the ABI.","triggerScenarios":"dotnetInitializeModule(internals) reads internals[RuntimeAPI].runtimeBuildInfo.gitHash and compares to the compiled-in GitHash. A non-empty mismatch throws before any exports are registered.","commonSituations":"Using a dotnet.runtime.js (loader) from one build/SDK and a dotnet.js / BrowserHost from another; partial package upgrade where some runtime files were cached; mixing a locally built runtime with an SDK-published loader.","solutions":["Use all runtime assets (loader dotnet.runtime.js, native dotnet.js, dotnet.wasm) from the same SDK/runtime build.","Clear the browser cache and re-publish so the gitHash-bearing files are consistent.","If building locally, ensure the loader and the native host module are produced in the same build."],"exampleFix":"<!-- before: loader from SDK A, native host from SDK B -->\n<script src=\"_framework/dotnet.runtime.js\" from SDK A></script>\n\n<!-- after: re-publish with a single SDK so all _framework/* files share one gitHash -->\ndotnet publish -c Release","handlingStrategy":"validation","validationCode":"function loaderMatchesHost(loaderHash: string, hostHash: string): boolean {\n  return !loaderHash || !hostHash || loaderHash === hostHash;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Take all runtime files (dotnet.runtime.js, dotnet.js, dotnet.wasm) from a single SDK build.","Clear browser caches after upgrading the runtime.","When building locally, produce the loader and native host in the same build."],"tags":["version","build","loader","configuration"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}