Skip to content

ObjectLoader: Fix log regression.#33240

Merged
Mugen87 merged 2 commits into
mrdoob:devfrom
Om-Mishra09:fix/objectloader-error-shadowing
Mar 25, 2026
Merged

ObjectLoader: Fix log regression.#33240
Mugen87 merged 2 commits into
mrdoob:devfrom
Om-Mishra09:fix/objectloader-error-shadowing

Conversation

@Om-Mishra09

Copy link
Copy Markdown
Contributor

Description
This PR fixes a critical variable shadowing bug inside ObjectLoader.js that causes the application to crash instead of gracefully handling malformed JSON.

Inside ObjectLoader.load(), when JSON.parse fails, the error is caught by a catch ( error ) block. However, the block then attempts to call error( ... ) using the imported logger utility. Because the caught exception variable shadows the imported function, this triggers a TypeError: error is not a function, crashing the execution entirely.

Changes:

  • Renamed the caught exception variable from error to e.
  • Passed e.message to the logger so the actual syntax error is properly surfaced to the developer.
  • Added a targeted QUnit test in ObjectLoader.tests.js to ensure malformed JSON is caught and logged without crashing.

All unit tests pass locally.

Comment thread src/loaders/ObjectLoader.js
@github-actions

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 360.01
85.46
360.01
85.46
+0 B
+0 B
WebGPU 633.22
175.54
633.22
175.54
+0 B
+0 B
WebGPU Nodes 631.34
175.25
631.34
175.25
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 492.21
120.03
492.21
120.03
+0 B
+0 B
WebGPU 705.25
190.44
705.25
190.44
+0 B
+0 B
WebGPU Nodes 654.47
177.68
654.47
177.68
+0 B
+0 B

@Mugen87 Mugen87 changed the title Fix variable shadowing in ObjectLoader catch block ObjectLoader: Fix log regression. Mar 25, 2026
@Mugen87 Mugen87 added this to the r184 milestone Mar 25, 2026
@Mugen87 Mugen87 merged commit fdd1b45 into mrdoob:dev Mar 25, 2026
10 checks passed
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