ed2aa9fd75
After upgrading to Next.js 13, we started seeing the following HMR
errors:
```sh
$ next dev
# ...
warn - Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/basic-features/fast-refresh#how-it-works
TypeError: Cannot read properties of null (reading 'length')
at eval (webpack-internal:///./node_modules/next/dist/client/dev/error-overlay/hot-dev-client.js:262:55)
```
This error appears related to the changes made in
https://github.com/vercel/next.js/pull/42350 (cc @alexkirsz). It appears
that `module.hot.check` will pass `null` when there are no updates:
```ts
/**
* Throws an exceptions if status() is not idle.
* Check all currently loaded modules for updates and apply updates if found.
* If no update was found, the callback is called with null.
* If autoApply is truthy the callback will be called with all modules that were disposed.
* apply() is automatically called with autoApply as options parameter.
* If autoApply is not set the callback will be called with all modules that will be disposed on apply().
* @param autoApply
*/
check(autoApply?: boolean): Promise<null|ModuleId[]>;
```
When `updatedModules` is `null`, we skip the `apply()` call as this was
producing `apply() is only allowed in ready status (state: idle)`
errors. This matches [the prior behavior when `autoApply` was
enabled](
|
||
---|---|---|
.. | ||
react-dev-overlay | ||
app-router-headers.ts | ||
app-router.tsx | ||
dynamic.tsx | ||
error-boundary.tsx | ||
error.tsx | ||
headers.ts | ||
hooks-server-context.ts | ||
infinite-promise.ts | ||
layout-router.tsx | ||
match-segments.ts | ||
navigation.ts | ||
not-found.ts | ||
redirect.ts | ||
reducer.ts | ||
render-from-template-context.tsx | ||
request-async-storage.ts | ||
static-generation-async-storage.ts | ||
static-generation-bailout.ts | ||
use-reducer-with-devtools.ts |