Repository navigation
Conversation
`loadScript` and `prefetchScript` awaited `resolveScript` outside the try/finally that removes the entry from `scriptsPromises`. When a resolver threw, the rejected promise stayed cached and every later call for the same script returned the same error without resolving again. Remove the cached promise when resolving fails and rethrow, so the next call can retry.
🦋 Changeset detectedLatest commit: 3cf56d7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@linhh-phv is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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
Fixes #1506.
loadScriptandprefetchScriptawaitedresolveScriptoutside thetry/finallythat removes the entry fromscriptsPromises. When a resolver threw (for example, the device was offline while resolving the script URL), the rejected promise stayed cached. Every later call for the same script then returned that error without calling the resolvers again, until the app was restarted.This PR catches errors from
resolveScript, removes the cached promise, and rethrows the same error:What does not change:
handleError/ theerrorevent still fire once, insideresolveScript.try/catch/finallyaround loading is untouched. I didn't moveresolveScriptinto it, because itscatchreadsscript.toObject()and callshandleErroragain, which would report a resolve error twice.A changeset (
patch) is included.Test plan
should retry loadScript after resolver failureandshould retry prefetchScript after resolver failure: the resolver rejects once, then resolves. The second call must succeed and call the resolver again.ScriptManagertests 50/50 pass.pnpm typecheck(packages/repack),biome checkon the changed files, and the full@callstack/repackjest suite (41 suites, 361 tests) pass.patch-packagepatch on top of 5.2.5 in a production app (iOS + Android, Module Federation v1). Opening a remote while offline, then going online and retrying, now loads the remote without restarting the app.