Next.js Discord

Discord Forum

Disable codeSplitting for backend code

Unanswered
Yellow-throated Vireo posted this in #help-forum
Open in Discord
Yellow-throated VireoOP
Hi all, code splitting has made it difficult to debug backend errors. In my Sentry stack, it looks something along the lines of > "Error in SomeClass.execute()" but when I want to see the stack that lead to this call, it's all abcabc.chunks.js. This makes it very difficult to see what the real stack was.

Ideally, I'd like to change something in my next.config.js so that it preserves the full stack for backend code. Claude gave me this code
  webpack(config, { isServer }) {
    if (isServer) {
      // Disable code splitting for server-side code only
      config.optimization.splitChunks = {
        cacheGroups: {
          default: false,
        },
      }
    }
    return config
  },

Does this look correct? What I want to avoid is disabling code splitting and this also disabling code splitting for frontend code, such that serving frontend pages turns out to be much slower.

4 Replies

I heard server components are doing code splitting by default
I think you can improve your error handling instead
Asiatic Lion
Hi @Yellow-throated Vireo Did disabling code-splitting config above worked for you?
Yellow-throated VireoOP
@Asiatic Lion - no, gave up on the endeavor

Shame - makes debugging a lot harder