# Understanding (and fixing ?) warning message

**URL:** <https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398>\
**Category:** General\
**Created:** [3 December 2023 09:44 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398 "2023-12-03T09:44:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [3 December 2023 09:44 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/1 "2023-12-03T09:44:19Z")

</div>

Hello,  
In my project, [World Meteorological Organization (WMO) Uses Node-RED to Modernize Sharing of Earth-System Data • FlowFuse](https://flowfuse.com/customer-stories/un-wmo-nr-data-sharing/), I am making extensive use of Redis and therefore of [node-red-contrib-redis (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-redis).  
It is an excellent tool to interface with Redis, however, the project is not active any more and the dev is not responding to issues on github.  
I have now this message when the flows are restarted:

```auto
"Deprecated API warning: Calls to RED.util.evaluateJSONataExpression must include a callback. This will not be optional in Node-RED 4.0. Please identify the node from the following stack and check for an update on npm. If none is available, please notify the node author."

```

and

```auto
Error
    at evaluateJSONataExpression (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:775:18)
    at Object.evaluateNodeProperty (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:673:18)
    at new RedisConfig (/data/node_modules/node-red-contrib-redis/redis.js:15:31)
    at Object.createNode (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/util.js:157:27)
    at Flow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:234:50)
    at async start (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/index.js:398:17)

```

If I understand correctly the message above, there is (will be) something to be fixed in `redis.js`.  
I suspect the offending code is:

```auto
  function RedisConfig(n) {
    RED.nodes.createNode(this, n);
    this.name = n.name;
    this.cluster = n.cluster;
    if (this.optionsType === "") {
      this.options = n.options;
    } else {
      this.options = RED.util.evaluateNodeProperty(
        n.options,
        n.optionsType,
        this
      );
    }
  }

```

Nevertheless, in the code I don't see any call to `RED.util.evaluateJSONataExpression` so, I wonder if I am looking at the right place.

So, two questions:

1. Is this effectively the (future) issue ?
2. Any suggestion on how to fix it ?

My knowledge of node.js and javascript is close to nil... Any help is welcome !  
Thanks.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 December 2023 09:53 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/2 "2023-12-03T09:53:55Z")

</div>

Hi @greengolfer

> **[Version 3.1 released](https://nodered.org/blog/2023/09/06/version-3-1-released#changes-to-how-environment-variables-are-evaluated)**
>
> Find out more on the blog

 ![Screenshot 2023-12-03 at 09.49.19](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/7/a7accaaa5e2cfeb66c872f5bc9a63cea4d39c08a.png)

In order to fix it.

This

```js
function RedisConfig(n) {
    RED.nodes.createNode(this, n);
    this.name = n.name;
    this.cluster = n.cluster;
    if (this.optionsType === "") {
      this.options = n.options;
    } else {
      this.options = RED.util.evaluateNodeProperty(
        n.options,
        n.optionsType,
        this
      );
    }
  }
  RED.nodes.registerType("redis-config", RedisConfig);

```

needs to be this

```js
function RedisConfig(n) {
    RED.nodes.createNode(this, n);
    this.name = n.name;
    this.cluster = n.cluster;
    if (this.optionsType === "") {
      this.options = n.options;
    } else {
      RED.util.evaluateNodeProperty(n.options, n.optionsType,this,(err,value) => {
           if(!err) {
            this.options = value
          }
      });
    }
  }
  RED.nodes.registerType("redis-config", RedisConfig);

```

If this Module is not updated, it will break in Node RED 4.0.0  
my suggestion is to attempt a PR on the project, and if still no luck - create a fork of the project, to create a version with the fix - I'm sure many users will appreciate it

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [3 December 2023 11:38 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/3 "2023-12-03T11:38:40Z")

</div>

Thanks for the quick answer.  
I have change the function code to what you suggested.  
At startup there is not any more the error, but, I have this in the debug window:

```auto
3 Dec 12:32:25 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:27 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:29 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:31 - [error] [redis-command:Getall] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:31 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:33 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:35 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:37 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:39 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:41 - [error] [redis-command:Getall] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:41 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:43 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:45 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:47 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:49 - [error] [redis-command:Set] TypeError: Cannot read properties of undefined (reading 'call')
3 Dec 12:32:51 - [error] [redis-command:Getall] TypeError: Cannot read properties of undefined (reading 'call')

```

So, I suspect the function RedisConfig doesn't quite work as it should.  
Maybe (probably), it is my lack of understanding of node.js but in the code you provided I don't quite get how `value` is initialized...

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 December 2023 11:51 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/4 "2023-12-03T11:51:20Z")

</div>

The last parameter of `RED.util.evaluateNodeProperty` is a callback with 2 arguments.

- `Error`
- `Value`

`Value` is the returned value after `RED.util.evaluateNodeProperty` is run and evaluated the query

This call is `asynchronous` meaning code can still be running past the point `evaluateNodeProperty` is executed, all whilst `evaluateNodeProperty` is still running.

Its very likely the nodes that are using the RedisConfig are trying to use something from the config before it has finished.

There may be an error provided by the `Error` parameter.

Try this - and see what is printed in the debug panel

```js
function RedisConfig(n) {
    RED.nodes.createNode(this, n);
    this.name = n.name;
    this.cluster = n.cluster;
    if (this.optionsType === "") {
        this.options = n.options;
    } else {
        RED.util.evaluateNodeProperty(n.options, n.optionsType, this, (err, value) => {
            if (!err) {
                this.options = value
                this.warn(value)

            } else {
                this.error(err)
            }
        });
    }
}
RED.nodes.registerType("redis-config", RedisConfig);

```

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [3 December 2023 11:56 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/5 "2023-12-03T11:56:05Z")

</div>

You have to be careful with asynchrony, JSONata is asynchronous, this is why the callback becomes required.  
I assume your child node gets `redis-config.options` before the promise (of options) is resolved

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 December 2023 11:57 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/6 "2023-12-03T11:57:17Z")

</div>

> [@marcus-j-davies](#):
>
> This call is `asynchronous` meaning code can still be running past the point `evaluateNodeProperty` is executed, all whilst `evaluateNodeProperty` is still running.
> 
> It's very likely the nodes that are using the RedisConfig are trying to use something from the config before it has finished.

Hence ☝

If that is true - then I am afraid this will require more work to fix

@knolleary, @Steve-Mcl  
It does raise the question of `done()` being available in the Init of a node?

I cant think of the top of my head if that is available during init of a node?  
I certainly don't have use a case for my nodes - but still?

Especially when a config node is using a method requiring a callback during start up?

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [3 December 2023 12:18 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/7 "2023-12-03T12:18:31Z")

</div>

I believe the reason this was not done is that it slows down the pallet loading.

Even if it would become asynchronous, it's also necessary to ensure that the config node is completely initialized before the child node initialization. What about parallel asynchronous functions. A real headache 😅

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 December 2023 12:32 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/8 "2023-12-03T12:32:40Z")

</div>

> [@GogoVega](#):
>
> it's also necessary to ensure that the config node is completely initialized before the child node initialization

This is the exact point I'm making.  
A child node is trying to use the config before its fully inited, because of the introduction of the required asynchronous callbacks.

Having the use of `done()` will go someway to fixing config nodes needing to use them.

This might require another topic 😅

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [3 December 2023 13:23 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/9 "2023-12-03T13:23:54Z")

</div>

Here is the starting log with the 2nd version:

```auto
3 Dec 14:20:37 - [warn] Deprecated API warning: Calls to RED.util.evaluateJSONataExpression must include a callback. This will not be optional in Node-RED 4.0. Please identify the node from the following stack and check for an update on npm. If none is available, please notify the node author.
3 Dec 14:20:37 - [warn] Error
    at evaluateJSONataExpression (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:775:18)
    at Object.evaluateNodeProperty (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:673:18)
    at new RedisConfig (/data/node_modules/node-red-contrib-redis/redis.js:15:18)
    at Object.createNode (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/util.js:157:27)
    at Flow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:234:50)
    at async Object.start [as startFlows] (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/index.js:398:17)
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?
3 Dec 14:20:37 - [info] Started flows

```

It looks like the initial issue is still there, plus new problems...

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [3 December 2023 13:32 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/10 "2023-12-03T13:32:18Z")

</div>

Oh hang on!

try this.

```js
function RedisConfig(n) {
    RED.nodes.createNode(this, n);
    this.name = n.name;
    this.cluster = n.cluster;
    if (this.optionsType === "") {
      this.options = n.options;
    } else {
      RED.util.evaluateNodeProperty(n.options, n.optionsType,this,undefined,(err,value) => {
           if(!err) {
            this.options = value
          }
      });
    }
  }
  RED.nodes.registerType("redis-config", RedisConfig);

```

it was treating the callback as an `msg` - and not a callback  
This might not stop the child nodes trying to use the Config too early, but that is a different problem if that still continues.

example:

```auto
3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?

```

So you might need to address that also

Remember to restart Node RED

---

<div class="post-metadata">

**Author:** ![greengolfer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/greengolfer/32/28276_2.png) [@greengolfer](https://discourse.nodered.org/u/greengolfer)\
**Post date:** [3 December 2023 14:08 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/11 "2023-12-03T14:08:58Z")

</div>

The last code fixed the issue. Thanks !

`3 Dec 14:20:37 - [error] [redis-config:Cluster] Missing options in the redis config - Are you upgrading from old version?`

Was a consequence of the other problem.

The new code fixed the issue. No more warning about the missing callback and no error like above.

All good. I'll propose a PR to github. Hopefully, it will be approved, otherwise, I'll create a fork.

Thanks again!!

---

<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:** [17 December 2023 14:09 UTC](https://discourse.nodered.org/t/understanding-and-fixing-warning-message/83398/12 "2023-12-17T14:09:23Z")

</div>

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