Sls deploy - RangeError: Maximum call stack size exceeded

Deploying with latest release (1.52) - today’s error is:
RangeError: Maximum call stack size exceeded at Function.[Symbol.hasInstance] (<anonymous>) at WriteStream (/builds/[yada]/node_modules/graceful-fs/graceful-fs.js:217:14)

I think I’m going to have to update my deployment script to use the last stable version

1 Like

Yup just changing the install serverless line in my CI script fixed it:

- npm install -g serverless

to:

- npm install -g serverless@1.51

This error is almost always means you have a problem with recursion in JavaScript code, as there isn’t any other way in JavaScript to consume lots of stack. Sometimes calling a recursive function over and over again, causes the browser to send you Maximum call stack size exceeded error message as the memory that can be allocated for your use is not unlimited.

How to fix it?

Wrap your recursive function call into a -

  • setTimeout
  • setImmediate
  • process.nextTick

Also, you can localize the issue by setting a breakpoint on RangeError type of exception , and then adjust the code appropriately.