Script-ordering bug: rpc is not defined in refreshStats / loadDatabases (and any other component that calls rpc()) #24
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_db#24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
Opening
/hero_db/ui(e.g. through hero_os): browser console immediately throwsStats card stays empty, database list never populates.
Root cause
In
crates/hero_db_ui/templates/base.htmlthe<script>that definesrpc()sits at line ~132, which is after{% block content %}(line 124). Child components (stats_card.html,database_manager.html, ...) inject their<script>blocks via{% block content %}and each one callsrpc(...)immediately at the bottom of its own block:In the rendered HTML, those component scripts appear at lines ~168–351. The
rpc()definition appears at line ~4291. JS function declarations do not hoist across<script>blocks, so when the early scripts callrpc(...), it doesn't exist yet →ReferenceError.Fix
Move the
<script>block that definesrpc()(and thegetSelectedDb()helper next to it, lines ~130–155 ofbase.html) to before{% block content %}— either inside<head>or at the top of<body>before the content block is rendered. Single move, ~15 lines.No dependencies on the DOM in
rpc()itself, so head-level placement is safe.Alternative (not recommended)
Wrap each component's bare bottom-of-script call (
refreshStats();,loadDatabases();) in aDOMContentLoadedhandler. Works, but touches 7+ component templates; one base.html move is cleaner.Verification path
/hero_db/uistandalone (not via hero_os) and confirm same console errors before fix.ReferenceErrorin console.