Skip to content

fix(dashboard): pass nodeMap into Runtime QuotaGroup - #12868

Merged
diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.51from
HouMinXi:fix/runtime-quotagroup-nodemap
Sep 7, 2026
Merged

diegosouzapw merged 2 commits into
diegosouzapw:release/v3.8.51from
HouMinXi:fix/runtime-quotagroup-nodemap

Conversation

@HouMinXi

@HouMinXi HouMinXi commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Bug

/dashboard/runtime throws ReferenceError: nodeMap is not defined when a quota monitor is in error, exhausted, or alerting.

Empty monitor lists never reach that path. quotaMonitorEnabled defaults to false, so the page stays idle unless monitors are turned on.

No upstream issue.

Cause

QuotaGroup is a module-level function in RuntimePageClient.tsx. It reads nodeMap, which only exists inside RuntimePageClient (from useProviderNodeMap()). That identifier is not in scope at the module level.

Landed in a7ae955 (v3.8.36, #4854). The existing unit file only fed empty monitors, and vitest excluded it (#8618).

The Chinese string "内部服务器错误" on this page is the per-page RSC publicSystem.error catalog. It is not this crash.

Fix

Pass nodeMap as a prop into QuotaGroup at the exhausted, alerting, and error call sites.

useProviderNodeMap() already returns Map (never undefined). resolveProviderName already uses nodeMap?.get.

Tests

  • Empty monitors still pass.
  • Fixture with status: "error" and status: "exhausted" mounts QuotaGroup. Throws ReferenceError before the prop; green after.
  • Dropping the parameter from the function signature throws the same ReferenceError again.
  • Dropping only the JSX prop stays green (undefined map is a valid fallback).
  • Removed tests/unit/ui/runtime-page-client.test.tsx from the vitest exclude list.

warning → alerting remap is not in this PR.

Risk

Small. Empty-monitor path is unchanged. The new prop is the same Map the parent already held.

File-size cap for this file: 1201 → 1222 (prettier wrap on the three call sites).

HouMinXi added a commit to HouMinXi/OmniRoute that referenced this pull request Sep 6, 2026
…gment

Signed-off-by: Minxi Hou <houminxi@gmail.com>
@HouMinXi

HouMinXi commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Looked at ceca5c585 on RuntimePageClient.tsx.

QuotaGroup is a module-level function. nodeMap only exists inside RuntimePageClient, so the identifier was out of scope. Passing the map as a prop is the right fix.

One review note asked whether the hook can return undefined. It cannot: useProviderNodeMap() is typed as Map and starts as new Map(). resolveProviderName already uses nodeMap?.get. Dropping only the JSX prop stays green; dropping the parameter from the function signature throws ReferenceError: nodeMap is not defined again.

No further code change from that note.

Lock: tests/unit/ui/runtime-page-client.test.tsx — empty monitors still pass; status: "error" / "exhausted" mounts QuotaGroup.

QuotaGroup is a module-level sibling of RuntimePageClient and was
reading nodeMap from the parent's closure. That identifier is not in
scope, so a quota monitor with status error/exhausted/alerting throws
ReferenceError. Thread the map as a prop. Keep the empty-monitor path
green; the new fixture mounts QuotaGroup.

Signed-off-by: Minxi Hou <houminxi@gmail.com>
…gment

Signed-off-by: Minxi Hou <houminxi@gmail.com>
@HouMinXi
HouMinXi force-pushed the fix/runtime-quotagroup-nodemap branch from 142e418 to 270fe36 Compare September 7, 2026 02:42
@HouMinXi

HouMinXi commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto upstream/release/v3.8.51 b345c7f6c (#12870 OpenCode v2 plugin).

  • 142e418a14e → 270fe362810
  • range-diff identity (eq=2); all commits GPG G
  • 2 unique commit(s) ahead, 0 behind
  • --force-with-lease to HouMinXi:fix/runtime-quotagroup-nodemap

@diegosouzapw
diegosouzapw merged commit d4d2e68 into diegosouzapw:release/v3.8.51 Sep 7, 2026
8 of 16 checks passed
@HouMinXi
HouMinXi deleted the fix/runtime-quotagroup-nodemap branch September 7, 2026 13:27
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
)

Validado numa worktree combinada com as 16 PRs desta leva sobre `release/v3.8.51`: typecheck:core limpo, check-file-size e check-changelog-integrity OK, complexity 2788/3218 e cognitive 1261/1437 (ambos sob a baseline), ESLint 0 erros nos 152 arquivos alterados, 771 testes unitários focados, 49 de integração e a suíte vitest:ui completa (2149) verdes.

O `nodeMap` lido do closure de `RuntimePageClient` por uma função de nível de módulo é uma bomba-relógio silenciosa: só explode quando um monitor entra em error/exhausted/alerting, e o teste existente só alimentava listas vazias. Tirar o arquivo do exclude do vitest vale tanto quanto o fix — confirmei aqui que `tests/unit/ui/runtime-page-client.test.tsx` agora roda na `test:vitest:ui` e passa.

A anotação sobre o "内部服务器错误" ser o catálogo RSC da página, e não o crash, poupou o próximo a caçar fantasma.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants