Netlify build command with error RangeError: Maximum call stack size exceeded during functions bundling

  • App: tik2.netlify.app
  • DNS issues? No
  • Build problems?Yes, latest deploy: Netlify App

The error:
`Internal error during “Functions bundling”
Error message
RangeError: Maximum call stack size exceeded

Error location
During Functions bundling
at Array.filter ()
at shouldTranspile (/opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:65:38)
at /opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:74:67
at Array.every ()
at shouldTranspile (/opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:74:45)
at /opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:74:67
at Array.every ()
at shouldTranspile (/opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:74:45)
at /opt/homebrew/lib/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:74:67
at Array.every ()

Resolved config
build:
environment:
- NODE_VERSION
publish: /Users/thome/fun/public
publishOrigin: config
functionsDirectory: /Users/thome/fun/functions`

Hey @tik9

Can you try the solutions offered in this post

1 Like

Hi,

I am experiencing the same errors with my nextjs project, all of a sudden. Was working fine until today. I did not change much. Attached is the full log. I have doubled checked my code for recursive functions and double imports etc. That is not the issue.

Any suggestions on how to move forward here!?

I tried updating my deps + next version.

8:17:11 PM: (@netlify/plugin-nextjs onBuild completed in 198ms)
8:17:11 PM: ​
8:17:11 PM: Functions bundling                                            
8:17:11 PM: ────────────────────────────────────────────────────────────────
8:17:11 PM: ​
8:17:11 PM: Packaging Functions from .netlify/functions-internal directory:
8:17:11 PM:  - ___netlify-handler/___netlify-handler.js
8:17:11 PM:  - ___netlify-odb-handler/___netlify-odb-handler.js
8:17:11 PM:  - _ipx/_ipx.js
8:17:11 PM: ​
8:17:11 PM: Packaging Functions from functions directory:
8:17:11 PM:  - cleanCristinData.js
8:17:11 PM:  - date2text.js
8:17:11 PM:  - getClockValue.js
8:17:11 PM:  - getCurrTheme.js
8:17:11 PM:  - loadPosts.js
8:17:11 PM: ​
8:17:47 PM: ​
8:17:47 PM: Internal error during "Functions bundling"                    
8:17:47 PM: ────────────────────────────────────────────────────────────────
8:17:47 PM: ​
8:17:47 PM:   Error message
8:17:47 PM:   RangeError: Maximum call stack size exceeded
8:17:47 PM: ​
8:17:47 PM:   Error location
8:17:47 PM:   During Functions bundling
8:17:47 PM:       at Map.has (<anonymous>)
8:17:47 PM:       at shouldTranspile (file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:76:15)
8:17:47 PM:       at file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:96:67
8:17:47 PM:       at Array.every (<anonymous>)
8:17:47 PM:       at shouldTranspile (file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:96:45)
8:17:47 PM:       at file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:96:67
8:17:47 PM:       at Array.every (<anonymous>)
8:17:47 PM:       at shouldTranspile (file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:96:45)
8:17:47 PM:       at file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:96:67
8:17:47 PM:       at Array.every (<anonymous>)
8:17:47 PM: ​
8:17:47 PM:   Resolved config
8:17:47 PM:   build:
8:17:47 PM:     command: npm run build
8:17:47 PM:     commandOrigin: ui
8:17:47 PM:     environment:
8:17:47 PM:       - NEXT_PRIVATE_TARGET
8:17:47 PM:     publish: /opt/build/repo/.next
8:17:47 PM:     publishOrigin: ui
8:17:47 PM:   functions:
8:17:47 PM:     ___netlify-handler:
8:17:47 PM:       external_node_modules: []
8:17:47 PM:       included_files:
8:17:47 PM:         - .env
8:17:47 PM:         - .env.local
8:17:47 PM:         - .env.production
8:17:47 PM:         - .env.production.local
8:17:47 PM:         - ./public/locales/**
        - ./next-i18next.config.js
        - .next/server/**
        - .next/serverless/**
        - .next/*.json
        - .next/BUILD_ID
        - .next/static/chunks/webpack-middleware*.js
        - '!.next/server/**/*.js.nft.json'
        - '!.next/server/**/*.map'

Can’t say for sure, we’d need a reproduction to check this. Can you share a minimal reproduction repo?

Sure, how can I share it with you in the best possible way? the github repo should be easy to clone and run (npm run dev or npm run build + npm run start in the root folder). GitHub - aleksati/aleksati: my site

Looks like one of your custom functions from netlify/functions folder is either not supported, or triggering a bug on our end. I’ll pass this to devs for feedback.

1 Like

Hi,

Yes, I just discovered that the “netlify/functions” folder was pointing to my other “functions” folder located in the root of my nextjs project. That was the problem. They are folder with totally different kind of “functions”.

I set the netlify functions folder back to default (“not set”). Now it seems to work fine again.

Thanks!

Which other “functions” folder? I see just 1 in your repo. And I deployed your site with default settings and that had the same issue.

Are these functions:

image

not meant to be used as Netlify Functions?

1 Like

I’m stuck on this exact issue and have repo to demonstrate the issue.

For reference, here is a failed deploy for that repo: Netlify App

This is derived from another project which was building and deploying just fine a day or so ago. But I changed something without realizing it and now seem unable to restore the working configuration. But unless I’m missing something, this configuration should work. But the netlify build step locally and on netlify.com shows that something’s amiss.

Not sure what you’re trying, @jneander. You don’t need to use tsc to build Netlify Functions. Just leave the .ts file in your repo and Netlify would bundle that as a function.

If I need to have specific build steps, I’ll need to retain control over the build process and not delegate that to Netlify. This is a simplified example just to show that something is amiss. It leaves out more of the use case.

After posting this, I tried different configurations and hit the same issue multiple ways, including without using TypeScript. Only when I gave CommonJS to Netlify did it finally work mostly as expected. This issue was resolved, which seems to point to how Netlify’s build step is handling ES Modules as the cause. For other reasons, I still can’t get this deployed successfully.

We don’t support processed source files being sent to us for Functions bundling. For us, the expected use case is to place your source files in the repo and allow us to bundle those. You can choose to do it some other way, but we can’t assure it would work fine, or provide support with that.

If you wish to share a reproduction without you doing the processing, I’m happy to check and give it a go.

I’ve pushed a commit which removes TypeScript from the equation. Same error.

This seems counter to the way the tooling works. netlify build will not run without a build script defined in package.json.

I believe that Hrishikesh was not saying you couldn’t name your npm script build, but that you shouldn’t pre-process your input files, you should just submit them as uncompiled and let us bundle them for you.

Is there something amiss with that last version of the repo that I pushed? It has no build step prior to Netlify’s process, and continues to fail at the bundling.

Please share a link to the build.

Made some changes: Hrishikesh-K/forums-74480 (github.com) (most were probably not required), but it works: forums-74480.netlify.app/.netlify/functions/index