nuxt: Cannot convert undefined or null to object in vue-server-renderer

Versions

  • nuxt: v2.14.7
  • node: v10.21.0

Reproduction

I have no idea how to reproduce this sadly, it just occurs suddenly and requires a restart of nuxt to go away. Some time later the problem usually reoccurs.

Running nuxt in SSR mode with -m=client

TypeError
Cannot convert undefined or null to object
node_modules/@nuxt/vue-renderer/dist/vue-renderer.js
open in editor

    const { clientManifest, modernManifest } = this.serverContext.resources;
    const legacyAssets = clientManifest.assetsMapping;
    const modernAssets = modernManifest.assetsMapping;
    const mapping = {};

    Object.keys(legacyAssets).forEach((componentHash) => {
      const modernComponentAssets = modernAssets[componentHash] || [];
      legacyAssets[componentHash].forEach((legacyAssetName, index) => {
        mapping[legacyAssetName] = modernComponentAssets[index];
      });
    });
                

 
Js

ModernRenderer.get assetsMapping [as assetsMapping]@4041:12
node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:4041:12
ModernRenderer.get assetsMapping [as assetsMapping]
node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:4077:33
scripts.replace
node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:4075:35
ModernRenderer.renderScripts
node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:3978:19
ModernRenderer.render
internal/process/next_tick.js:68:7
process._tickCallback 

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 11
  • Comments: 17 (3 by maintainers)

Most upvoted comments

This issue is reproducible in https://github.com/WordPress/openverse-frontend

Run the development server then reload the page during re-compilation (for example make trivial changes like updating tailwind classes back and forth) and eventually it will happen as long as every once in a while you reload the page after recompilation then after the page loads, reload again. It appears to be the second reload that causes this error. I’m able to reproduce it consistently in around 30 seconds now.

Note: it does also happen during normal development, not just during a stress-test like environment I’ve described above. Given 20 minutes of working on a particular issue or iterating on a page or component and this will almost inevitably happen.

Can second this, happens to me too. Not deterministic, it just occurs after running the development server for some time.
What makes this especially annoying is that a server restart takes about 3 minutes for our app, so as soon as I see that error I know I’m in for a waiting session 🙄

i feel like this happens when i reload the page while the build process is running

In src/renderers/modern.js:

    delete clientManifest.assetsMapping
    delete modernManifest.assetsMapping

May I ask why is it deleting stuff from an object it doesn’t own?

Because ModernRenderer may be created more than once (loadResources() calls createRenderer() when there are updates), clientManifest.assetsMapping may have already been deleted, which causes Object.keys(legacyAssets) to throw this exception.

Hi @danielroe,

Sorry for the silence.

I just looked at my config, I’m not changing maxSize or splitChunks in my project. If maxSize or splitChunks is set to anything it’s nuxt or webpack’s default.

Do you think that overriding splitting completely in dev mode will maybe solve the issue then?

This is happening with me to at 2.15.3

EDIT: Also with modern: 'client' EDIT2: I’m using node version v14