# TypeError: node.scope.forEach is not a function

**URL:** <https://discourse.nodered.org/t/typeerror-node-scope-foreach-is-not-a-function/23412>\
**Category:** General\
**Created:** [21 March 2020 14:14 UTC](https://discourse.nodered.org/t/typeerror-node-scope-foreach-is-not-a-function/23412 "2020-03-21T14:14:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 March 2020 14:14 UTC](https://discourse.nodered.org/t/typeerror-node-scope-foreach-is-not-a-function/23412/1 "2020-03-21T14:14:05Z")

</div>

Is there a known issue when creating a subflow from selected nodes and then restarting getting the error

```auto
TypeError: node.scope.forEach is not a function
    at Subflow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:245:36)
    at Subflow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Subflow.js:317:15)
    at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:208:41)
    at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:345:33)
    at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
    at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
    at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
    at Pending.run (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:483:13)
    at Scheduler._drain (/usr/lib/node_modules/node-red/node_modules/when/lib/Scheduler.js:62:19)
    at Scheduler.drain (/usr/lib/node_modules/node-red/node_modules/when/lib/Scheduler.js:27:9)

```

The subflow also did not seem to be receiving messages. When I removed it, created a new emtpy subflow and copied the nodes into it then it seemed ok.

node-red 1.0.4, nodejs 12.16.1

---

<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:** [21 March 2020 14:30 UTC](https://discourse.nodered.org/t/typeerror-node-scope-foreach-is-not-a-function/23412/2 "2020-03-21T14:30:37Z")

</div>

Any known issue of that sort of error would be on [https://github.com/node-red/node-red/issues](https://github.com/node-red/node-red/issues)

I've not seen that error before and I've been exercising the convert-subflow path a lot in the last few days.

Does it happen every time? Does it happen regardless of what nodes you are converting?

Looking at the line throwing the error, it is related to the Complete node. Do you have any Complete nodes? Are they included in the selection you are converting?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 March 2020 15:54 UTC](https://discourse.nodered.org/t/typeerror-node-scope-foreach-is-not-a-function/23412/3 "2020-03-21T15:54:34Z")

</div>

> [@knolleary](#):
>
> Do you have any Complete nodes? Are they included in the selection you are converting?

Yes and Yes. I don't know whether it is reproducible, I will try again.  
It is used with an email node.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [21 March 2020 17:34 UTC](https://discourse.nodered.org/t/typeerror-node-scope-foreach-is-not-a-function/23412/4 "2020-03-21T17:34:50Z")

</div>

It is repeatable, in fact it seems to need just any node and an associated Complete node. Mark them and make a subflow from selected nodes, then on deploy it gives the error. If instead a new subflow is created and the nodes copied/pasted then there is no error.  
Issue submitted [https://github.com/node-red/node-red/issues/2514](https://github.com/node-red/node-red/issues/2514)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 May 2020 17:35 UTC](https://discourse.nodered.org/t/typeerror-node-scope-foreach-is-not-a-function/23412/5 "2020-05-20T17:35:08Z")

</div>

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