Wait for getFilesForRoute promise to fulfill before timeout in dev mode (#27395)
The fix in PR #25749 only works some of the time. The reason why it doesn't work all of the time is because the `devBuildResolve` function is called when the assets have been built, but this can happen before the `getFilesForRoute` promise chain has completed, and thus the `cancelled` variable could not yet have been updated. To fix this we wait for the `getFilesForRoute` promise chain to be fulfilled and then resolve the `devBuildPromise` promise afterwards. This allows the `getFilesForRoute` promise chain to be fulfilled before and the `cancelled` variable can be updated accordingly. If an error is thrown somewhere in the `getFilesForRoute` promise chain, i.e. due to a failed fetch request, then that will also resolve the `devBuildPromise` and the error will bubble up to ultimately become a `routeChangeError` which will reload the page. With this fix the need to listen for HMR events has become obsolete as regardless of when the HMR build/sync events complete we still want to ensure that the `getFilesForRoute` promise chain has been fulfilled before resolving the `devBuildPromise`. Co-authored-by:Tobias Järvelöv <tobias.jarvelov@oderland.se> Co-authored-by:
JJ Kasper <jj@jjsweb.site>
Showing
Please
register
or
sign in
to comment