fix(map): resolve loading stuck caused by module-level promise ref#16
Merged
Conversation
The module-level mapModulePromise held a single promise reference that the useEffect .then() consumed. Two issues caused the map to stay in loading state intermittently: 1. On chunk-load failure the rejected (but truthy) promise prevented the nullish-coalescing fallback from firing, so TaiwanMap stayed null with no retry path. 2. Under React 19 Strict Mode the cancelled-flag lifecycle could race with the shared promise resolution timing. Replace the stored promise with a fire-and-forget preload -- the bundler caches the module anyway, so a second import() in useEffect resolves instantly. Also add a one-shot retry on transient chunk-load failures.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Map module frequently got stuck in loading state (showing placeholder indefinitely), but worked fine when opening a new tab.
Root cause: The module-level
mapModulePromisevariable held a single promise reference consumed byuseEffect's.then(). This had two failure modes:??fallback -- no retry,TaiwanMapstayednullforever.cancelledflag lifecycle could race with the shared promise resolution timing.Fix: Replace the stored promise reference with a fire-and-forget preload. The bundler caches the module internally, so a fresh
import()call inuseEffectresolves instantly from cache. Also adds a one-shot retry on transient chunk-load failures.Test plan