Netlify serverless function bundling failing with "Maximum Call Stack size exceeded"

Site is https://magical-druid-ccf35e.netlify.app
failing on build but working with Netlify CLI locally. Couldn’t identify anywhere in my serverless functions that could recursively exhaust the call stack. Wondering if it could be a problem with a dependency?
Here are the build logs

1:17:25 AM: Netlify Build                                                 
1:17:25 AM: ────────────────────────────────────────────────────────────────
1:17:25 AM: ​
1:17:25 AM: ❯ Version
1:17:25 AM:   @netlify/build 29.20.12
1:17:25 AM: ​
1:17:25 AM: ❯ Flags
1:17:25 AM:   baseRelDir: true
1:17:25 AM:   buildId: 64fd5f468aeeda00084a6dd7
1:17:25 AM:   deployId: 64fd5f468aeeda00084a6dd9
1:17:25 AM: ​
1:17:25 AM: ❯ Current directory
1:17:25 AM:   /opt/build/repo
1:17:25 AM: ​
1:17:25 AM: ❯ Config file
1:17:25 AM:   No config file was defined: using default values.
1:17:25 AM: ​
1:17:25 AM: ❯ Context
1:17:25 AM:   deploy-preview
1:17:25 AM: ​
1:17:25 AM: Build command from Netlify app                                
1:17:25 AM: ────────────────────────────────────────────────────────────────
1:17:25 AM: ​
1:17:25 AM: $ CI= npm run build
1:17:25 AM: > devwebsitev2@0.0.1 build
1:17:25 AM: > astro build
1:17:27 AM: 06:17:27 AM [content] Types generated 442ms
1:17:27 AM: 06:17:27 AM [build] output target: static
1:17:27 AM: 06:17:27 AM [build] Collecting build info...
1:17:27 AM: 06:17:27 AM [build] Completed in 478ms.
1:17:27 AM: 06:17:27 AM [build] Building static entrypoints...
1:17:28 AM: 06:17:28 AM [build] Completed in 1.58s.
1:17:28 AM: 
1:17:28 AM:  building client 
1:17:28 AM: Completed in 51ms.
1:17:28 AM: 
1:17:28 AM: 
1:17:28 AM:  generating static routes 
1:17:28 AM: ▶ src/pages/index.astro
1:17:28 AM:   └─ /index.html (+14ms)
1:17:28 AM: ▶ src/pages/posts/[slug].astro
1:17:28 AM:   ├─ /posts/gameboy-emulator/index.html (+6ms)
1:17:28 AM:   ├─ /posts/people-counter/index.html (+9ms)
1:17:28 AM:   └─ /posts/portfolio-website/index.html (+12ms)
1:17:28 AM: ▶ src/pages/blog.astro
1:17:28 AM:   └─ /blog/index.html (+3ms)
1:17:28 AM: Completed in 35ms.
1:17:28 AM: 
1:17:28 AM: 06:17:28 AM [build] 5 page(s) built in 2.15s
1:17:28 AM: 06:17:28 AM [build] Complete!
1:17:28 AM: ​
1:17:28 AM: (build.command completed in 3.2s)
1:17:28 AM: ​
1:17:28 AM: Functions bundling                                            
1:17:28 AM: ────────────────────────────────────────────────────────────────
1:17:28 AM: ​
1:17:28 AM: Packaging Functions from netlify/functions directory:
1:17:28 AM:  - askquestion.js
1:17:28 AM:  - index.js
1:17:28 AM: ​
1:17:30 AM: ​
1:17:30 AM: Internal error during Functions bundling                    
1:17:30 AM: ────────────────────────────────────────────────────────────────
1:17:30 AM: ​
1:17:30 AM:   Error message
1:17:30 AM:   RangeError: Maximum call stack size exceeded
1:17:30 AM: ​
1:17:30 AM:   Error location
1:17:30 AM:   During Functions bundling
1:17:30 AM:       at Map.has (<anonymous>)
1:17:30 AM:       at shouldTranspile (file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:58:15)
1:17:30 AM:       at file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:78:67
1:17:30 AM:       at Array.every (<anonymous>)
1:17:30 AM:       at shouldTranspile (file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:78:45)
1:17:30 AM:       at file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:78:67
1:17:30 AM:       at Array.every (<anonymous>)
1:17:30 AM:       at shouldTranspile (file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:78:45)
1:17:30 AM:       at file:///opt/buildhome/node-deps/node_modules/@netlify/zip-it-and-ship-it/dist/runtimes/node/bundlers/nft/es_modules.js:78:67
1:17:30 AM:       at Array.every (<anonymous>)
1:17:30 AM: ​
1:17:30 AM:   Resolved config
1:17:30 AM:   build:
1:17:30 AM:     command: CI= npm run build
1:17:30 AM:     commandOrigin: ui
1:17:30 AM:     environment:
1:17:30 AM:       - CI
1:17:30 AM:       - DEPRECATED
1:17:30 AM:       - OPENAI_API_KEY
1:17:30 AM:       - REVIEW_ID
1:17:30 AM:     publish: /opt/build/repo/dist
1:17:30 AM:     publishOrigin: ui
1:17:30 AM:   functionsDirectory: /opt/build/repo/netlify/functions
1:17:30 AM: Build failed due to an internal system error: Build script returned non-zero exit code: 4
1:17:30 AM: Failing build: Failed to build site
1:17:31 AM: Finished processing build request in 25.923s
1:17:30 AM: Failed during stage 'building site': Build script returned non-zero exit code: 4 (https://ntl.fyi/exit-code-4)
1:17:38 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)

Duplicate of: Maximum call stack size error - Support - Netlify Support Forums

I checked out the other threads, but wasn’t able to find a solution in any of them about my problem. Here’s a link to my repo, my changes are in the pr

It seems like another person implementing a chatbot also was having this problem in the other thread. Maybe it’s a problem with a common way we are implementing it that the lambda can’t handle?

I never mentioned a solution. I simply pointed you to the other thread where there’s already a discussion happening, so you can continue there and we don’t have to keep replying the same thing in multiple threads.

The “solution” is to wait. Our devs are looking at this and we’d post at least in one of the threads when this is fixed.

Your reply came off a little condescending/sarcastic. I was just trying to provide some insight into the problem. This was my first time posting on Netlify’s forums, and I was a little confused about your initial response of just linking another thread with zero context. After doing some more research, it is clear to me that this is likely a dependency problem with the hnswlib-node package’s natively compiled binaries not being compatible with AWS lambda, So using it with lambda required containerization of the backend which can then be triggered by the lambda. I’m sure your devs are already aware of this, but it seems like any fix is likely far off in the future. Actually the “solution” for me has been to simply migrate from this sub-par service to AWS, where I was able to troubleshoot and fix these problems on my own without running into vague debug logging and an impolite response to a support ticket, but I do thank you for giving me the motivation to switch!

For anyone else coming to this thread, the issue should now be fixed.