Skip to content

Fix ReferenceError: _ is not defined on page load#6367

Open
gcharpe1604 wants to merge 1 commit intosugarlabs:masterfrom
gcharpe1604:fix/reference-error-underscore-loading
Open

Fix ReferenceError: _ is not defined on page load#6367
gcharpe1604 wants to merge 1 commit intosugarlabs:masterfrom
gcharpe1604:fix/reference-error-underscore-loading

Conversation

@gcharpe1604
Copy link

@gcharpe1604 gcharpe1604 commented Mar 23, 2026

Description

This PR resolves the ReferenceError: _ is not defined that occurs during the initial loading of MusicBlocks. The error was caused by a race condition where some components attempted to use the translation function _ before it was fully loaded and defined.

Related Issue

Fixes #6365

PR Category

  • Bug Fix — Fixes a bug or incorrect behavior
  • Feature — Adds new functionality
  • Performance — Improves performance (load time, memory, rendering, etc.)
  • Tests — Adds or updates test coverage
  • Documentation — Updates to docs, comments, or README

Changes Made

  • Updated loader.js: Added logoconstants to the configuration to ensure the translation function is available before constants are initialized.
  • Improved index.html: Added a defensive fallback for the translation function in the inline loading script to prevent errors if the translator loads slowly.

Testing Performed

  • Ran the full automated test suite (npm test).
  • Verified that all 3967 tests passed.
  • Manually verified the script loading order and the defensive check in the code.

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have followed the project's coding style guidelines.
  • I have run npm run lint and npx prettier --check . with no errors.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@gcharpe1604 gcharpe1604 force-pushed the fix/reference-error-underscore-loading branch from f21767e to 997d4b1 Compare March 23, 2026 06:41
@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions github-actions bot added bug fix Fixes a bug or incorrect behavior size/XS Extra small: < 10 lines changed area/javascript Changes to JS source files area/core Changes to core app entry files labels Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Changes to core app entry files area/javascript Changes to JS source files bug fix Fixes a bug or incorrect behavior size/XS Extra small: < 10 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ReferenceError: _ is not defined on Page Load

1 participant