Home
Support Forums

Builds started to fail all of a sudden

So the site has been deployed to netlify hundreds of times without issues. Today all build started to fail with the same reason:

3:28:21 PM: > Build error occurred
3:28:21 PM: /opt/build/repo/.next/serverless/chunks/7849.js:73167
3:28:21 PM: 	__webpack_require__(953952),
3:28:21 PM: 	                    ^^^^^^
3:28:21 PM: SyntaxError: Unexpected number
3:28:21 PM:     at wrapSafe (internal/modules/cjs/loader.js:1054:16)
3:28:21 PM:     at Module._compile (internal/modules/cjs/loader.js:1102:27)
3:28:21 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
3:28:21 PM:     at Module.load (internal/modules/cjs/loader.js:986:32)
3:28:21 PM:     at Function.Module._load (internal/modules/cjs/loader.js:879:14)
3:28:21 PM:     at Module.require (internal/modules/cjs/loader.js:1026:19)
3:28:21 PM:     at require (internal/modules/cjs/helpers.js:72:18)
3:28:21 PM:     at Object.__webpack_require__.f.require (/opt/build/repo/.next/serverless/pages/account.js:1288:28)
3:28:21 PM:     at /opt/build/repo/.next/serverless/pages/account.js:1211:40
3:28:21 PM:     at Array.reduce (<anonymous>) {
3:28:21 PM:   type: 'SyntaxError'
3:28:21 PM: }

I tried deploying a branch that has previously worked, but even that failed. Clearing the cache before building did not help and the app builds locally without any issues.

Hi @jayp

What version of Next.js are you using?
What version of webpack are you using?

Hi @coelmay !
Nextjs version is 11.1.0 and webpack 5 that comes along with it.

Can you post the link to your full deploy log (if they are public)?

Unfortunately those are not public. I did however find this:

3:51:18 PM:  ./node_modules/vm2/lib/main.js

3:51:18 PM: Module not found: Can't resolve 'coffee-script' in '/opt/build/repo/node_modules/vm2/lib'

3:51:18 PM: ./node_modules/vm2/lib/main.js

I just can’t figure out what has changed since the exact same app deployed perfectly yesterday. VM2 is not in our dependency tree at all.

can you provide a site name please, @jayp ? thank you

2 Likes

Site name is sackey-ecom-dev. There are tons of failed builds, all for the same reason. I also tried running the build locally with netlify cli and that one does not give an error. So local builds are working just fine.

Just for trying, what happens when you add coffee-script to your package.json as a dependency?

Then the complaint about coffee-script goes away but the webpack issue remains the same. That coffee-script issue has been there on success builds all along. Local build log does not have that issue though.

I wonder if you try disabling webpack5 @jayp

To do so add webpack5: false to your next.config.js e.g.

module.exports = {
  // Note: no `future` key here
  webpack5: false,
  /**
   * rest of config
   */
}

If nothing else, it will eliminate this as a factor in the build

That is a good suggestion. I tried it and the error changed a bit:

2:56:41 PM: Module not found: Can't resolve 'coffee-script' in '/opt/build/repo/node_modules/vm2/lib'
2:56:41 PM: info  - Collecting page data...
2:56:45 PM: > Build error occurred
2:56:45 PM: /opt/build/repo/.next/serverless/pages/account.js:159156
2:56:45 PM: 	__webpack_require__("uH/u"),
2:56:45 PM: 	                    ^^^^^^
2:56:45 PM: SyntaxError: Unexpected string
2:56:45 PM:     at wrapSafe (internal/modules/cjs/loader.js:988:16)
2:56:45 PM:     at Module._compile (internal/modules/cjs/loader.js:1036:27)
2:56:45 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2:56:45 PM:     at Module.load (internal/modules/cjs/loader.js:937:32)
2:56:45 PM:     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2:56:45 PM:     at Module.require (internal/modules/cjs/loader.js:961:19)
2:56:45 PM:     at require (internal/modules/cjs/helpers.js:92:18)
2:56:45 PM:     at Object.requirePage (/opt/build/repo/node_modules/next/dist/server/require.js:47:12)
2:56:45 PM:     at Object.loadComponents (/opt/build/repo/node_modules/next/dist/server/load-components.js:31:47)
2:56:45 PM:     at /opt/build/repo/node_modules/next/dist/build/utils.js:566:59 {
2:56:45 PM:   type: 'SyntaxError'
2:56:45 PM: }
2:56:46 PM:

One thing that seems to be fixing the issue is moving an authenticated call from getServerSideProps to client-side on one page that requires authentication. However, that feature has been there for a while already and there have been multiple successful builds after it… Could it be that when the app and that getserversideprops is built, the fail is caused by the missing session that is needed for the authenticated call…

Hi @jayp,

Thank you for the patience. We’d try to loop our NextJS experts to see what can be done here.

Hey there, @jayp

I chatted with one of our Nextjs experts, and they suggested trying either esbuild as your node_bundler or target experimental-serverless-trace in your next.config.js.

Can you give those both a try and let me know if you have any progress? If neither of those work, can you please respond with your public project repo as well? This will help us dive into this further. Thank you!

1 Like

I was able to get passed this issue by moving some of the authenticated calls from serverside to the client side.

However, another error showed up with the functions:
{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected string","trace":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected string"," at _loadUserApp (/var/runtime/UserFunction.js:98:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object.<anonymous> (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:1072:14)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)"," at Module.load (internal/modules/cjs/loader.js:937:32)"," at Function.Module._load (internal/modules/cjs/loader.js:778:12)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)"," at internal/main/run_main_module.js:17:47"]}

Again with code that has been working before. Has something changed how Netlify deploys functions? Is there are way to see the function log from aws?

None of the inline logging works as it seems the function crashes immediately. Some functions are working normally though. The crashing function also works once I remove Auth0 calls from it using that go through import { ManagementClient } from 'auth0'; . But there is no new code, those functions have been working for a long time until now.

What was the last thing you did that caused this? Did this happen after you implemented changes suggested by @hillary? Or something else?

I understand that you haven’t touched the function’s code, but probably you changed some other config that might have caused this?

1 Like