Skip to content

Fix race condition in asset loader when script tag hasn't loaded#102

Open
ndri wants to merge 1 commit intobeyonk:masterfrom
ndri:fix/asset-loader-race-condition
Open

Fix race condition in asset loader when script tag hasn't loaded#102
ndri wants to merge 1 commit intobeyonk:masterfrom
ndri:fix/asset-loader-race-condition

Conversation

@ndri
Copy link
Copy Markdown

@ndri ndri commented Mar 31, 2026

When multiple components mount simultaneously, the script tag may already exist in the DOM but mapboxgl hasn't finished loading yet. The loader would call cb() immediately, causing TypeError when trying to set accessToken on undefined.

Now checks if window.mapboxgl is available. If not, waits for the existing script's load event before calling the callback.

When multiple components mount simultaneously, the script tag may already
exist in the DOM but mapboxgl hasn't finished loading yet. The loader
would call cb() immediately, causing TypeError when trying to set
accessToken on undefined.

Now checks if window.mapboxgl is available. If not, waits for the
existing script's load event before calling the callback.
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.

1 participant