# Node-Red crashes with RangeError: Maximum call stack size exceeded

**URL:** <https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378>\
**Category:** General\
**Created:** [28 February 2020 14:44 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378 "2020-02-28T14:44:45Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![oliv3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliv3/32/7193_2.png) [@oliv3](https://discourse.nodered.org/u/oliv3)\
**Post date:** [12 March 2020 15:59 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378/21 "2020-03-12T15:59:31Z")

</div>

It looks like this:

 ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8c2cbbde5093f9803cfe03e82fe44f2b0838eef4.png)

---

<div class="post-metadata">

**Author:** ![oliv3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliv3/32/7193_2.png) [@oliv3](https://discourse.nodered.org/u/oliv3)\
**Post date:** [12 March 2020 16:00 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378/22 "2020-03-12T16:00:18Z")

</div>

So yes, the path is from a known Http In node, which is queried every 10 seconds

---

<div class="post-metadata">

**Author:** ![oliv3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliv3/32/7193_2.png) [@oliv3](https://discourse.nodered.org/u/oliv3)\
**Post date:** [15 March 2020 16:25 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378/23 "2020-03-15T16:25:48Z")

</div>

A new error appeared today (in the same endpoint):

```auto
kaalut-node-red | RangeError: Maximum call stack size exceeded
kaalut-node-red | at write (console.js:168:9)
kaalut-node-red | at Console.log (console.js:200:3)
kaalut-node-red | at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:289:13)
kaalut-node-red | at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7
kaalut-node-red | at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:336:12)
kaalut-node-red | at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)
kaalut-node-red | at compression (/data/node_modules/compression/index.js:220:5)
kaalut-node-red | at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
kaalut-node-red | at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:318:13)
kaalut-node-red | at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7
kaalut-node-red | RangeError: Maximum call stack size exceeded
kaalut-node-red | at Object.formatWithOptions (util.js:75:27)
kaalut-node-red | at Console.(anonymous function) (console.js:191:15)
kaalut-node-red | at Console.log (console.js:202:31)
kaalut-node-red | at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:289:13)
kaalut-node-red | at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7
kaalut-node-red | at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:336:12)
kaalut-node-red | at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)
kaalut-node-red | at Layer.handle_error (/usr/src/node-red/node_modules/express/lib/router/layer.js:67:12)
kaalut-node-red | at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:316:13)
kaalut-node-red | at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7

```

It happened after I made some changes in the flow:

In the flow, there's a KV store read, result was sent to a function node that deleted some req.query.headers fields.  
I set up another function node after the KV read, and that part stopped working, most probably because it was not using a copy of msg, so some headers where now missing in the second part.

But according [this](https://nodered.org/blog/2019/09/13/cloning-messages), messages are cloned by default so this should not happen ? Removing the delete msg.req.headers in the first part solved the problem in the second.

---

<div class="post-metadata">

**Author:** ![oliv3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliv3/32/7193_2.png) [@oliv3](https://discourse.nodered.org/u/oliv3)\
**Post date:** [15 March 2020 16:43 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378/24 "2020-03-15T16:43:17Z")

</div>

Now this is confusing:

 ![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5b5c3b031e7e8da556da4d77aa1794309f4b7e50.png)

I tried to pass the message in the "node.send()" node in 3 ways:

- return msg;
- node.send(msg, false);
- node.send(msg, true);

The "Delete" node deletes msg.req.query.uid. In all the cases, msg.red.query.uid is removed in the "Do nothing" node.

The flow:

```auto
[{"id":"14cd7d66.588e33","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"8968cc4c.3244f8","type":"http in","z":"14cd7d66.588e33","name":"","url":"/test","method":"get","upload":false,"swaggerDoc":"","x":260,"y":200,"wires":[["ce86c557.c1991","e41bebf2.226108","a40ad3ef.06da1"]]},{"id":"e41bebf2.226108","type":"debug","z":"14cd7d66.588e33","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":140,"wires":[]},{"id":"ce86c557.c1991","type":"http response","z":"14cd7d66.588e33","name":"","statusCode":"","headers":{},"x":450,"y":260,"wires":[]},{"id":"c6d0808c.2d4e08","type":"debug","z":"14cd7d66.588e33","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":160,"wires":[]},{"id":"4d7be408.6d20d4","type":"debug","z":"14cd7d66.588e33","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":240,"wires":[]},{"id":"a40ad3ef.06da1","type":"function","z":"14cd7d66.588e33","name":"node.send()","func":"// node.send(msg, false);\n\nreturn msg;","outputs":1,"noerr":0,"x":470,"y":200,"wires":[["3e7d50ce.e7d1d","6689df7f.67ad18"]]},{"id":"6689df7f.67ad18","type":"function","z":"14cd7d66.588e33","name":"Delete","func":"delete msg.req.query.uid;\n\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":160,"wires":[["c6d0808c.2d4e08"]]},{"id":"3e7d50ce.e7d1d","type":"function","z":"14cd7d66.588e33","name":"Do nothing","func":"\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":240,"wires":[["4d7be408.6d20d4"]]}]

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 March 2020 17:23 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378/25 "2020-03-15T17:23:13Z")

</div>

`msg.req` never gets cloned - it is a special edge case in all the cloning logic because it includes unclonable objects from the underlying HTTP library.

---

<div class="post-metadata">

**Author:** ![oliv3](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/oliv3/32/7193_2.png) [@oliv3](https://discourse.nodered.org/u/oliv3)\
**Post date:** [15 March 2020 23:21 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378/26 "2020-03-15T23:21:50Z")

</div>

Ok, good to know. Maybe need some documentation about the edge cases ? Thanks !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 May 2020 23:21 UTC](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378/27 "2020-05-14T23:21:52Z")

</div>

Closed on 14 May 2020 23:21 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

[Previous page](https://discourse.nodered.org/t/node-red-crashes-with-rangeerror-maximum-call-stack-size-exceeded/22378.md?page=1)
