Skip to content

Avoid monitor JavaScript redeclaration errors#221

Merged
TheWitness merged 1 commit into
Cacti:developfrom
godmafiaze:fix-220-monitor-js-redeclare
Jul 9, 2026
Merged

Avoid monitor JavaScript redeclaration errors#221
TheWitness merged 1 commit into
Cacti:developfrom
godmafiaze:fix-220-monitor-js-redeclare

Conversation

@godmafiaze

@godmafiaze godmafiaze commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This PR updates top-level declarations in js/monitor.js from let / const to var.

The Monitor page can reload content through AJAX. When monitor.js is executed more than once, top-level let / const declarations can throw JavaScript redeclaration errors, such as:

Uncaught SyntaxError: Identifier 'refreshMSeconds' has already been declared

This can prevent Monitor dropdowns and filter controls from applying changes correctly after an AJAX reload.

This change keeps block-scoped declarations inside functions unchanged and only adjusts the top-level declarations that may be executed more than once.

Fixes #220

Tested:

  • Verified the Monitor page no longer throws the refreshMSeconds redeclaration error
  • Verified Monitor dropdown/filter controls continue working after AJAX reload
  • Verified git diff --check returns no whitespace errors

@TheWitness TheWitness left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is interesting. I'm pretty sure I know how it happened. Good job!

@TheWitness

TheWitness commented Jul 9, 2026

Copy link
Copy Markdown
Member

@somethingwithproof, I think the AI did this one. It's a global either in layout.js or global_session.php. Pretty sure in global_session.php.

@TheWitness TheWitness merged commit ab0c5a0 into Cacti:develop Jul 9, 2026
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.

monitor.js throws redeclaration error after AJAX reload

2 participants