{"record":{"id":"bedb70d3fec3cb4a","repo":"koala73/worldmonitor","slug":"cannot-read-dashboard-entry-entrypath-error-message","errorCode":null,"errorMessage":"cannot read dashboard entry ${entryPath}: ${error.message}","messagePattern":"cannot read dashboard entry (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/bundle-budgets.mjs","lineNumber":208,"sourceCode":" * where the indices point into one `m.f=[…]` table and the list starts with\n * the imported chunk itself. Anything that breaks that shape throws: a parser\n * that silently measured the wrong list would let the application graph grow\n * unseen.\n */\nexport function deferredDashboardAppDependencies(distDir) {\n  const { dashboardPath, html } = readDashboardHtml(distDir);\n  const entryUrl = /<script\\b[^>]*\\btype=[\"']module[\"'][^>]*\\bsrc=[\"']([^\"']+\\.js(?:[?#][^\"']*)?)[\"']/i\n    .exec(html)?.[1];\n  const entryName = entryUrl ? assetFileNameFromUrl(entryUrl) : null;\n  if (!entryName) {\n    throw new Error(`no module entry script in ${dashboardPath} — run: ${BUILD_COMMANDS.dashboard}`);\n  }\n  const entryPath = join(distDir, 'assets', entryName);\n  let source;\n  try {\n    source = readFileSync(entryPath, 'utf8');\n  } catch (error) {\n    throw new Error(`cannot read dashboard entry ${entryPath}: ${error.message}`);\n  }\n\n  const appImport = /import\\(\\s*[\"']\\.\\/(App-[A-Za-z0-9_-]{8}\\.js)[\"']\\s*\\)/.exec(source);\n  if (!appImport) return null;\n  const appFile = appImport[1];\n  const unsupported = (reason) => new Error(\n    `${entryPath}: ${reason} for the deferred ./${appFile} import — the Vite loader shape changed; `\n    + 'update deferredDashboardAppDependencies in scripts/bundle-budgets.mjs',\n  );\n\n  const afterImport = source.slice(appImport.index + appImport[0].length);\n  const depsCall = /__vite__mapDeps\\(\\[([\\d,\\s]*)\\]\\)/.exec(afterImport);\n  if (!depsCall || afterImport.slice(0, depsCall.index).includes('import(')) {\n    throw unsupported('no Vite preload list');\n  }\n  const tableSource = /m\\.f=\\[([^\\]]*)\\]/.exec(source)?.[1];\n  let table;\n  try {","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/scripts/bundle-budgets.mjs#L190-L226","documentation":"After resolving the entry chunk name from dashboard.html, deferredDashboardAppDependencies reads dist/assets/<entry>.js to parse the Vite loader. If the file cannot be read, it throws including the underlying fs error message. This catches HTML/asset mismatches where the referenced entry chunk is missing from the build output.","triggerScenarios":"dashboard.html references an entry asset that does not exist in dist/assets/ — partial/cleaned build output, stale HTML from a previous build paired with pruned assets, wrong distDir whose assets/ subfolder lacks the file, or a permissions problem on the chunk.","commonSituations":"CI caches dashboard.html but not assets/; developer deletes assets/*.js while keeping HTML; concurrent builds racing and replacing hashed chunks; symlinked dist where assets/ resolves incorrectly.","solutions":["Run a fresh full BUILD_COMMANDS.dashboard build so HTML and assets/ are regenerated together","Confirm dist/assets/<entryName>.js exists (compare with the src in dashboard.html)","Wipe dist/ and rebuild if stale hashed chunks linger from an earlier build","Fix the distDir argument if it points at a directory missing the assets/ output"],"exampleFix":"// before: stale mismatched output\nrm dist/assets/*.js  // HTML still references removed entry\n// after\nrm -rf dist && npm run build:dashboard","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nconst entry = dist/assets/<entryName from html>;\nif (!existsSync(entry)) throw new Error(`entry chunk missing: ${entry} — rebuild dist/`);","typeGuard":"const entryChunkExists = (distDir, entryName) => existsSync(join(distDir, 'assets', entryName));","tryCatchPattern":"try {\n  const deps = deferredDashboardAppDependencies(distDir);\n} catch (e) {\n  if (e.message.includes('cannot read dashboard entry')) {\n    console.error('HTML/asset mismatch — wipe dist/ and rebuild the dashboard');\n    process.exitCode = 1;\n  } else throw e;\n}","preventionTips":["Regenerate HTML and assets together; never delete hashed chunks selectively","Wipe dist/ fully before a fresh build to avoid stale hash mismatches","Don't share dist/ between concurrent builds","Verify CI caches include assets/, not just HTML"],"tags":["build","file-not-found","vite","stale-artifacts"],"backgroundTag":"file-not-found","analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-09-15T16:44:39.439Z","contentChangedAt":"2026-09-15T16:44:39.439Z","schemaVersion":2},"datasetVersion":"2026-09-15T18:17:12.389Z"}