# Function node issues: Invalid Properties - noerr (Chrome) & closing editor while in Setup or Close tab

**URL:** <https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128>\
**Category:** Dashboard\
**Created:** [20 September 2020 21:02 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128 "2020-09-20T21:02:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pitus/32/28170_2.png) [@pitus](https://discourse.nodered.org/u/pitus)\
**Post date:** [20 September 2020 21:02 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/1 "2020-09-20T21:02:39Z")

</div>

My function node shows an error (red triangle) with a tooltip:

```auto
Invalid Properties
-noerr

```

I've seen a similar issue with an IE browser, but I'm using the latest Chrome on Windows and this will NOT go away even though there are no errors or warnings in the editor itself.

I've managed to narrow this down to a missing closing brace `}` for a conditional inside a `function` defined in the function node's code ... however the editor didn't show any issues with that so maybe you can improve the visual indicator for any such unpaired braces so other users don't struggle with this weird `-noerr` issue 😉

One annoying thing that I found in the editor is a warning about a misplaced `?` in the following code:

```auto
return condition
    ? 'true'
    : 'false';

```

It insists that the `?` must be on the same line as the return statement or condition, which is completely incomprehensible when I look at

```auto
return condition ?
    'true' :
    'false';

```

(my code is actually much longer, condition is complex and the two statements are also longer so both the `?` and `:` get lost at the end of long lines!

Also, when I switched the editor tabs from **Function** to either **Setup** or **Close** then hit **Done** , my Chrome DevTools stopped with a JavaScript error _(no error if I leave it with the **Function** tab active when hitting **Done** )_:

`TypeError: Cannot read property 'getTokens' of null`

this is in getTokens() called from:

- `$renderLine()`
- `$renderChanges`
- `_flush()`
- `schedule()`
- `setAnnotations()`
- `onChangeAnnotation()`
- `r._signal()`
- `setAnnotations()`
- `clearAnnotations()`
- `(anonymous)` - inside `ace.define("ace/mode/nrjavascript", [], ...)`
- `r._signal()`
- `terminate()`
- `$stopWorker()`
- `destroy()`
- `destroy()`
- `disposeEditor()`
- `oneditsave()`
- `click()`
- ...

---

<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 September 2020 08:22 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/2 "2020-09-21T08:22:18Z")

</div>

Can you post the function node with the missing brace that caused the problem please? Use the `</>` button at the top of the forum edit window when pasting it in.

Also post a function node containing the code with the failing conditional statement please.

Please make each one a complete function node so we can paste it in and test.

---

<div class="post-metadata">

**Author:** ![pitus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pitus/32/28170_2.png) [@pitus](https://discourse.nodered.org/u/pitus)\
**Post date:** [24 September 2020 00:09 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/3 "2020-09-24T00:09:48Z")

</div>

@Colin

Here's a simple function with a missing closing `}` which shows an error triangle and tooltip with `Invalid properties: - noerr` reference:

```auto
if( msg.topic === 'start' ) {
    node.warn('starting...');

return msg;

```

---

<div class="post-metadata">

**Author:** ![pitus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pitus/32/28170_2.png) [@pitus](https://discourse.nodered.org/u/pitus)\
**Post date:** [24 September 2020 00:12 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/4 "2020-09-24T00:12:49Z")

</div>

@Colin

And here's a function with the conditional that shows a warning triangle in the editor (on the line with `?` - `Bad line breaking before '?'`), but works just fine.

```auto
node.warn( msg.topic === 'start'
    ? 'starting...'
    : 'other...'
);
return msg;

```

---

<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:** [24 September 2020 08:26 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/5 "2020-09-24T08:26:18Z")

</div>

> [@pitus](#):
>
> Here's a simple function with a missing closing `}`

> [@pitus](#):
>
> Bad line breaking before '?'

Yes, I see those too. I don't think this is a node-red issue as it uses the ACE editor if I remember rightly which I believe also does the syntax checking. I don't know where one would report such issues.

---

<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:** [24 September 2020 08:31 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/6 "2020-09-24T08:31:51Z")

</div>

We have just updated to the latest version of ACE in git and it appears to handle the code sample you've shared properly:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f07e7d5d78d98cda9802d34baa25edad6c98af42.png)

The `noerr` thing is an artefact of how we are able to pass errors between the ACE syntax highlighting/validation and the editor. It isn't ideal, but we don't have any other way to flag up such issues once the edit dialog is closed and the ACE editor no longer exists.

---

<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:** [24 September 2020 08:52 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/7 "2020-09-24T08:52:10Z")

</div>

Does the new one show an error in the editor for the missing brace? It doesn't show anything at the moment, only on the node itself after closing the editor.

---

<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:** [24 September 2020 09:02 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/8 "2020-09-24T09:02:00Z")

</div>

> [@Colin](#):
>
> Does the new one show an error in the editor for the missing brace?

Ah good point. No it doesn't - but that's an issue with us, not ACE.

Because the code you put inside the Function node is actually the body of an async function, before we pass it up to ACE to validate, we wrap it in a function:

So when you have the following in the edit box:

```auto
if( msg.topic === 'start' ) {
    node.warn('starting...');

return msg;

```

We actually pass this to ACE to validate:

```auto
async function __nodered__ (msg) {
   if( msg.topic === 'start' ) {
       node.warn('starting...');

   return msg;
}

```

This stops it warning if you use `await` in your function code.

However, it means in the case you've highlighted, it considers the bracket for the `if` statement to have a closing bracket (the one we add), and the bracket that isn't closed is actually on the first line. That puts the warning on the first line and we hide it because it's out of range of _your_ code.

That doesn't stop the count of errors to be correct (`noerrs` === `number of errors`) - which is why the node is (correctly) marked as invalid, despite nothing showing in the edit dialog.

So need to be a bit smarter about handling errors that get flagged on the first (added) line.

---

<div class="post-metadata">

**Author:** ![pitus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pitus/32/28170_2.png) [@pitus](https://discourse.nodered.org/u/pitus)\
**Post date:** [25 September 2020 00:19 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/9 "2020-09-25T00:19:18Z")

</div>

So, how is ACE flagging this as an error or how exactly do you "hide" the first and last line from being displayed?  
Perhaps you can catch that "invisible" ACE error and indicate it to the NR user somehow, within the Function editor?  
The -noerrs is very confusing and very hard to find as the user doesn't know what they're looking for - my example was very short, but it took me a while (binary search - deleting blocks of code) to find the missing brace ☹

---

<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:** [25 September 2020 07:27 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/10 "2020-09-25T07:27:44Z")

</div>

@pitus I know what needs to be done - I was just reporting back to @Colin that the scenario he had raised was an extra issue that needed handling.

You can see the fix here: [https://github.com/node-red/node-red/commit/81dc3de26aa312577a2265d5ca389b6aaf8dcaf6](https://github.com/node-red/node-red/commit/81dc3de26aa312577a2265d5ca389b6aaf8dcaf6)

In summary, it ensures all errors are visible to the user in the edit dialog and in the case of the missing `{` error, it attempts to move the error to the right line in the code.

---

<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:** [25 October 2020 07:27 UTC](https://discourse.nodered.org/t/function-node-issues-invalid-properties-noerr-chrome-closing-editor-while-in-setup-or-close-tab/33128/11 "2020-10-25T07:27:51Z")

</div>

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