Skip to content

Fix race condition between simulator init and project loading#11196

Merged
riknoll merged 2 commits intomicrosoft:masterfrom
microbit-matt-hillsdon:await-mount-before-load
Mar 19, 2026
Merged

Fix race condition between simulator init and project loading#11196
riknoll merged 2 commits intomicrosoft:masterfrom
microbit-matt-hillsdon:await-mount-before-load

Conversation

@microbit-matt-hillsdon
Copy link
Contributor

Gate internalLoadHeaderAsync on componentDidMount completion so the simulator driver is guaranteed to exist before project loading accesses it. Add a defensive null guard in stopSimulator.

Return the newProject() promise from the app init callback chain so errors propagate to the catch handler avoiding a blank screen if this step fails during init.

Fixes microsoft/pxt-microbit#6081

Note: You can get a deterministic repro by adding e.g. await new Promise(resolve => setTimeout(resolve, 2_000)); to simulator's initAsync.

Gate internalLoadHeaderAsync on componentDidMount completion so the
simulator driver is guaranteed to exist before project loading accesses
it. Add a defensive null guard in stopSimulator.

Return the newProject() promise from the app init callback chain so errors
propagate to the catch handler avoiding a blank screen if this step fails
during init.

Fixes microsoft/pxt-microbit#6081
Copy link
Member

@riknoll riknoll left a comment

Choose a reason for hiding this comment

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

this stuff is always tricky, so we'll need to really hammer on this while testing, but LGTM

@riknoll riknoll enabled auto-merge (squash) March 19, 2026 21:35
@riknoll riknoll merged commit 50486a9 into microsoft:master Mar 19, 2026
12 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.

Timing-related page load issue that leaves UI in broken state (simulator driver init)

2 participants