You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ScriptManager caches the rejected promise when a resolver throws, so loadScript/prefetchScript never retry #1506
If a script resolver throws, ScriptManager keeps the rejected promise in scriptsPromises. Every later loadScript / prefetchScript call for the same script returns that same error and never calls the resolvers again. The only way out is to restart the app.
In loadScript and prefetchScript, resolveScript is awaited before the try / finally that removes the entry from scriptsPromises:
constloadProcess=async()=>{letscript=awaitthis.resolveScript(/* ... */);// a throw here skips the finally belowtry{// ...}catch(error){// ...}finally{// should delete script promise even script faileddeletethis.scriptsPromises[uniqueId];}};this.scriptsPromises[uniqueId]=loadProcess();
So the "delete even if it failed" path only runs for loading errors, not for resolving errors. The same pattern is in prefetchScript. It also affects loadScript after a failed prefetchScript, because loadScript awaits the cached prefetch promise and rethrows its error.
Expected: after a resolver error (e.g. the device was offline while the resolver fetched the script URL), the next loadScript call runs the resolvers again, the same way it already retries after a failed native load.
Actual: the next loadScript calls reject right away with the first error, even after the network is back. In our app a user who opened a mini app while offline could not open it again until they killed and reopened the app. A retry button on an error boundary or React.lazy remount did not help.
System Info
React Native 0.79.7 (New Architecture, Hermes)
@callstack/repack 5.2.5, bundler webpack 5, Module Federation v1
iOS and Android, release builds
Re.Pack Version
5.2.5. The code is unchanged in 5.4.2 and on main (32c32c0).
await ScriptManager.shared.loadScript('miniApp') rejects with Network request failed, as expected.
Call await ScriptManager.shared.loadScript('miniApp') again: it rejects with the same error and resolver was called only once.
In an app: make the resolver depend on the network (for example, fetch the version or URL of a remote), open a federated remote while offline, turn the network back on, then try to open it again.
I have a fix ready and will open a PR: delete the cached promise when resolveScript throws, then rethrow.
Activity
feat(repack-devtools-plugin): trace ScriptManager calls and inject fa…
feat(repack-devtools-plugin): trace ScriptManager calls and inject fa…