Next.js 13.4.12 build failing on @netlify/plugin-nextjs version 4.41.3

As of this morning, all environments for our site (metrie.com) are failing to build with the error:

`TypeError: Class constructor URL cannot be invoked without 'new'` .

The error was first reported on our production site, which has not had a code change since November 20th. Other environments are now failing with the same error.

Here is a full log of a failing build: Netlify

So far we’ve observed that updating the Node version to 20, 22, or higher does not fix the issue.
We next tried updating Next.js to 13.5, and updating the Next.js plugin to >5.0 (so far we’ve tried 5.0.0 and 5.9.1). The build does succeed, but this breaks site functionality.

Is Next.js 13.4, and/or @netlify/plugin-nextjs v4 no longer supported as of today? We had builds succeeding as recently as yesterday.

We’ve responded to this in the helpdesk.

Hi there, are you able to provide a link to the response? I am unable to find it and am running into a similar issue with an app. Thanks!

Quoting:

As for the build failing on Next Runtime v4, there’s a chance that one of your dependencies might have changed or got a bug due to which this is failing. Currently, you are the only one who’s reporting this issue, so it’s not something widespread or known to us. There’s a chance that something specific in your codebase is causing this. Here’s another example that can cause this: HookWebpackError: Class constructor URL cannot be invoked without ‘new’ · Issue #48296 · vercel/next.js. While I don’t recommend using Next.js < 13.5 along with Runtime v4 anymore, if you absolutely want to stick to that, the next steps would be to run a build locally using Netlify CLI. You can do so by running netlify build --offline . You can then inspect your .next directory to see if your have URL anywhere in your codebase (due to your or a library code).

We have not heard back after that.

Thank you for the update and the suggestions. We’ve been digging into a couple of things including looking for URL without the new keyword in the results of a netlify build --offline call as suggested, and looking into how feasible it will be to update to Next.js 13.5 and a newer @netlify/plugin-nextjs version.

No luck on finding references to URL yet, but we will keep trying and let you know what we find.

Hrishikesh and team,

So far we haven’t had any luck isolating a code change that might’ve caused this issue. We have been running netlify build --offline as suggested, and even adding the --debug flag, but the process only fails once it gets to the “Functions bundling” step and the error reporting there is not very helpful.

The way forward for us that looks the most promising is to upgrade to Next 13.5 and the 5.0 version of the Netlify Next.js plugin. We’re going down that route now.

Would still like some help from the Netlify team understanding and reporting back to our client, what happened on 12/19, what changed that caused builds to begin failing without any code or configuration changes on our part. While investigating, we noticed that new versions of several Netlify plugins were released on or immediately before the 19th, including:

  • @netlify/plugin-nextjs
  • @netlify/functions
  • @netlify/config
  • @netlify/build

Can you help us understand if, as part of these releases, any support for older plugin versions (specifically plugin-nextjs version 4.41.3) might have been deprecated on or about that time? That’s the only thing we can figure out, as to how builds started breaking, and immediately resume working when we upgrade the plugin to 5.0.

  • @netlify/plugin-nextjs hasn’t been updated on the v4 branch for months now.
  • @netlify/functions majorly provides type definitions and some other helper functions (for Function scheduling or using On Demand Builders). We’re not modifying anything in On Demand Builders either as we don’t intend that to be a long-term feature anymore. No plans to deprate it yet, but also no plans to develop anything in that area.
  • @netlify/build simply runs the build. It doesn’t interefer by its own in Functions bundling.
  • @netlify/config simply resolves your configuration based on UI settings + netlify.toml. It doesn’t do much in terms of Functions bundling either.

All this to say, I don’t think any of these plugins or packages have the potential to cause anything to break with your site alone. If you can produce a minimal reproduction, we can take a look and provide deeper insights, but I don’t have anything conclusive from our end that would explain why just 1 site broke.

Hrishikesh,

I will discuss with our client if we can commit the time to doing a minimal reproduction. If we’re able to create a branch of our private repository that includes just Next.js and a handful of dependencies, can we invite someone from the Netlify team to view the code, or would this need to be an entirely different repo and Netlify project / configuration?

1 Like

Entirely different is preferred as we can more easily identify issues in an isolated minimal reproduction. But if that’s not possible, feel free to invite me: hrishikesh-k (Hrishikesh Kokate) · GitHub