Skip to content

[2.x] fix(js): capture extension name by value in initializer error closure#4482

Merged
imorland merged 1 commit into2.xfrom
im/fix-initializer-error-extension-name
Mar 21, 2026
Merged

[2.x] fix(js): capture extension name by value in initializer error closure#4482
imorland merged 1 commit into2.xfrom
im/fix-initializer-error-extension-name

Conversation

@imorland
Copy link
Member

Summary

Fixes #4293.

When an initializer throws, the error is deferred into a caughtInitializationErrors closure and fired after mount() completes. The closure was reading this.currentInitializerExtension at call time — by which point the property holds the last initializer's name, not the one that threw. So every error message incorrectly blamed the final extension in the boot sequence.

The fix is a one-liner: capture this.currentInitializerExtension into a local const inside the catch block before creating the closure, so each closure closes over its own immutable value.

extend.ts already does this correctly (const extension = app.currentInitializerExtension at line ~34). The catch block was just not updated to match when currentInitializerExtension was introduced in #4134.

Test plan

  • New integration test: registers two initializers where the first throws, calls initialize(), and asserts the error closure names bad-ext (the throwing extension), not good-ext (the last one to run)
  • Run yarn test in framework/core/js/

When an initializer throws, the error is deferred into a closure and
fired after mount(). The closure was reading this.currentInitializerExtension
at call time — by which point the property holds the last initializer's
name, not the one that threw.

Capture the name into a local const at catch time so each closure
closes over its own immutable value. Mirrors what extend.ts already
does correctly.

Fixes #4293
@imorland imorland requested a review from a team as a code owner March 21, 2026 23:21
@imorland imorland changed the title fix(js): capture extension name by value in initializer error closure [2.x] fix(js): capture extension name by value in initializer error closure Mar 21, 2026
@imorland imorland added this to the 2.0.0-beta.8 milestone Mar 21, 2026
@imorland imorland merged commit 9ae2598 into 2.x Mar 21, 2026
25 checks passed
@imorland imorland deleted the im/fix-initializer-error-extension-name branch March 21, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.x] Application.initialize error message refers to the wrong extension/initializer name

1 participant