-
Notifications
You must be signed in to change notification settings - Fork 27.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read properties of null (reading 'length') #43143
Comments
I somehow think this is a minification issue, because when I looked at the code there was a guard for the length check closest to the offending line, on the source code, but not in the minified code... it's a bit hard to trigger, usually you need to make a syntax error on a page, save, and fix the error to trigger it, but it doesn't always happen to me. |
…43145) 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 #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](https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/hmr/HotModuleReplacement.runtime.js#L266-L272). Fixes #43143. Also reported on Stack Overflow: - https://stackoverflow.com/questions/74415937/nextjs-typeerror-cannot-read-properties-of-null-reading-length - https://stackoverflow.com/questions/74504229/nextjs-v-13-typeerror-cannot-read-properties-of-null-reading-length I tested this change locally and no longer see these HMR errors. ## Bug - [X] Related issues linked using `fixes #number` - no related issues - [X] Integration tests added - there aren't any existing tests, afaict - [X] Errors have a helpful link attached, see `contributing.md` - N/A Co-authored-by: JJ Kasper <[email protected]>
Thanks for fixing. I also just noticed this locally too. ed2aa9f?diff=unified#diff-e676ab1125f4857b4e42850e2f067267f5fb2fbbf7464b88e70a7399d9a1940bR179 looks like the line that is most critical in this fix to me. |
…ercel#43145) 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 vercel#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](https://github.com/webpack/webpack/blob/8241da7f1e75c5581ba535d127fa66aeb9eb2ac8/lib/hmr/HotModuleReplacement.runtime.js#L266-L272). Fixes vercel#43143. Also reported on Stack Overflow: - https://stackoverflow.com/questions/74415937/nextjs-typeerror-cannot-read-properties-of-null-reading-length - https://stackoverflow.com/questions/74504229/nextjs-v-13-typeerror-cannot-read-properties-of-null-reading-length I tested this change locally and no longer see these HMR errors. ## Bug - [X] Related issues linked using `fixes #number` - no related issues - [X] Integration tests added - there aren't any existing tests, afaict - [X] Errors have a helpful link attached, see `contributing.md` - N/A Co-authored-by: JJ Kasper <[email protected]>
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Home
Binaries:
Node: 16.14.2
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.5-canary.2
eslint-config-next: 13.0.4
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I just updated an existing Next app to the latest next 13 and in the console when I run yarn dev I see an error:
I don't think this is coming from my code as I only use length in one place and it should be ok.
I googled it and came up with a few people on SO that have the issue (in the last week or so) but I don't see any thing in here about it: https://stackoverflow.com/questions/74415937/nextjs-typeerror-cannot-read-properties-of-null-reading-length
Nothing seems broken, I just see it in the console.
Expected Behavior
no error message in console
Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster
n/a
To Reproduce
for me it is simply doing yarn dev,
The text was updated successfully, but these errors were encountered: