Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wait for getFilesForRoute promise to fulfill before timeout in dev mode
The fix in PR vercel#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`.
- Loading branch information