Any reason why is this build is failing?

Info:
siteName: bright-gecko-c4e431
Problem: I’m having a weird error on production, the application is working normally locally using npm run dev or next dev.

Hope you could give me some advice or hint about my issue, I would appreciate it.

12:26:08 AM:    ╵
12:26:08 AM:     public/assets/scss/font-awesome/_list.scss 14:9  @import
12:26:08 AM:     public/assets/scss/font-awesome.scss 12:9        @import
12:26:08 AM:     public/assets/scss/app.scss 15:9                 root stylesheet
12:26:10 AM: WARNING: 2 repetitive deprecation warnings omitted.
12:26:31 AM: thread '<unnamed>' panicked at 'Infinite loop detected (current pass = 203)
Code    0:
12:26:31 AM: "use strict";
12:26:31 AM: (self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([
12:26:31 AM:     [
12:26:31 AM:         834
12:26:31 AM:     ],
12:26:31 AM:     {
12:26:31 AM:         78481: function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
12:26:31 AM:             var _firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(64888);
12:26:31 AM:             (function() {
12:26:31 AM:                 var Uk, il, k, aa = "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) {
...
... more code...
12:26:40 AM:                 function Xe(a) {
12:26:40 AM:                     return !("Safari" == ve(a = a || K()) || a.toLowerCase().match(/iphone|ipad|ipod/));
12:26:40 AM:                 }
12:26:40 AM:                 function Ye() {
12:26:40 AM:                     var a = l.___jsl;
12:26:40 AM:                     if (a && a.H) {
12:26:40 AM:                         for(var b in a.H)if (a.H[b].r = a.H[b].r || [], a.H[b].L = a.H[b].L || [], a.H[b].r = a.H[b].L.concat(), a.CP) for(var c = 0; c < a.CP.length; c++)a.CP[c] = null;
12:26:40 AM:                     }
12:26:40 AM:                 }
12:26:40 AM:                 function Ze(a, b) {
12:26:40 AM:                     if (a > b) throw Error("Short​
12:26:41 AM: ────────────────────────────────────────────────────────────────
12:26:41 AM:   "build.command" failed                                        
12:26:41 AM: ────────────────────────────────────────────────────────────────
12:26:41 AM: ​
12:26:41 AM:   Error message
12:26:41 AM:   Command was killed with SIGABRT (Aborted): next build
12:26:41 AM: ​
12:26:41 AM:   Error location
12:26:41 AM:   In Build command from Netlify app:
12:26:41 AM:   next build
12:26:41 AM: ​
12:26:41 AM:   Resolved config
12:26:41 AM:   build:
12:26:41 AM:     command: next build
12:26:41 AM:     commandOrigin: ui
12:26:41 AM:     environment:
12:26:41 AM:       - NEXT_PRIVATE_TARGET
12:26:41 AM:     publish: /opt/build/repo/.next
12:26:41 AM:     publishOrigin: ui
12:26:41 AM:   functionsDirectory: /opt/build/repo/functions
12:26:41 AM:   plugins:
12:26:41 AM:     - inputs: {}
12:26:41 AM:       origin: ui
12:26:41 AM:       package: '@netlify/plugin-nextjs'
12:26:41 AM: Caching artifacts
12:26:42 AM: Started saving node modules
12:26:42 AM: Finished saving node modules
12:26:42 AM: Started saving build plugins
12:26:42 AM: Finished saving build plugins
12:26:42 AM: Started saving pip cache
12:26:42 AM: Finished saving pip cache
12:26:42 AM: Started saving emacs cask dependencies
12:26:42 AM: Finished saving emacs cask dependencies
12:26:42 AM: Started saving maven dependencies
12:26:42 AM: Finished saving maven dependencies
12:26:42 AM: Started saving boot dependencies
12:26:42 AM: Finished saving boot dependencies
12:26:42 AM: Started saving rust rustup cache
12:26:42 AM: Finished saving rust rustup cache
12:26:42 AM: Started saving go dependencies
12:26:42 AM: Finished saving go dependencies
12:26:42 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:26:43 AM: Failing build: Failed to build site
12:26:43 AM: Finished processing build request in 1m36.034347481s

Hey @WIckedNash

Based in this line from the log, there is an infinite loop somewhere in your code. Without seeing it, it impossible to say where.

Have you tried running npm run build locally to see if you get the same error?

Yup, I ran the command locally and It didn’t work, after debugging I deployed it again and worked this time, thanks