# My old flow shows errors after update

**URL:** <https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341>\
**Category:** General\
**Tags:** function-node\
**Created:** [19 April 2024 12:44 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341 "2024-04-19T12:44:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.nodered.org/u/blob)\
**Post date:** [19 April 2024 12:44 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/1 "2024-04-19T12:44:51Z")

</div>

Hello,

I had a flow created and it was updated last year. After that i didn't update it. Recently one of my friend updated with this command - "npm install -g --unsafe-perm node-red" and immediately after that my flow was not responding on the browser which was open till then and accessible. I rebooted my raspberry pi4.

After that when I opened the browser to see the flow after the pi rebooted, I noticed many of my previous code showed errors. I have given the screenshots of the errors. Please note that before updating and rebooting the pi same flow was working perfectly fine.

My Node red version is 14.20.0  
My npm version is 6.14.17  
I'm posting some of the screenshots of errors I'm getting in my flow.

 ![Screenshot 2024-04-19 180833](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/8/883ca91fa060dd91fc9d107f812b7e00a8259335.png)  
 ![Screenshot 2024-04-19 180949](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/e/0e191a0eaaa75b9ecf3594c5e76e8f203e977bba.png)  
 ![Screenshot 2024-04-19 181113](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/8/486bf1fa807716c97c350d6f38cf635cef9e5db2.png)

Kindly help me resolve the above error. Also, is there a way to rollback the latest update which could bring back my older version which was compatible with the flow's code?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [19 April 2024 13:02 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/2 "2024-04-19T13:02:27Z")

</div>

I think it is the "Code Editor" being very strict about the syntax.  
In your first screenshot you need to declare the variables in each of the FOR loops  
e.g.` for (let i=19; i<37; i++)`

---

<div class="post-metadata">

**Author:** ![kitori](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kitori](https://discourse.nodered.org/u/kitori)\
**Post date:** [19 April 2024 13:02 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/3 "2024-04-19T13:02:52Z")

</div>

You must declare **i**

typing for in a function node give me this  
 ![grafik](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9cc3f31c2842383dc880190a5d9dd918b0f21669.png)

```auto
for (let index = 0; index < array.length; index++) {
    const element = array[index];
    
}

```

* * *

Calculating a timediff --\> use miliseconds

> **[Date.prototype.getMilliseconds() - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds)**
>
> The getMilliseconds() method of Date instances returns the milliseconds for this date according to local time.

* * *

**buf** needs to be declared somewhere

i use [https://flows.nodered.org/node/node-red-contrib-buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser) when i must convert buffer data to something else.

---

<div class="post-metadata">

**Author:** ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.nodered.org/u/blob)\
**Post date:** [22 April 2024 06:39 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/4 "2024-04-22T06:39:31Z")

</div>

Thanks for reply dynamicdave and kitori.

---

<div class="post-metadata">

**Author:** ![piwi447](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/piwi447/32/67335_2.png) [@piwi447](https://discourse.nodered.org/u/piwi447)\
**Post date:** [22 April 2024 20:29 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/5 "2024-04-22T20:29:58Z")

</div>

Nice answer but it is really abnormal that an upgrade is able to make code working well going wrong just because more strict syntax control.  
An update should not be allowed without informing clearly the list of Java code that will be refused if the update is done.  
This is not fair that after an update you need to recheck all code to see if they are still working.

Pierre

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 April 2024 20:39 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/6 "2024-04-22T20:39:53Z")

</div>

> [@piwi447](#):
>
> it is really abnormal that an upgrade is able to make code working well going wrong just because more strict syntax control

The error is a "soft error". Your functions still work. You can also disable the errors directly in the function node by clicking the bulb icon that appears when you put the cursor on any of the errors & chose "disable checks" (I forget the exact option name)

> [@piwi447](#):
>
> This is not fair that after an update you need to recheck all code to see if they are still working

You don't. And you can disable the type checks completely so they never bother you again but you would be doing yourself a disservice.

If you truly wish to remove the things telling you you have potentially "bad code", let me know and I'll tell you how.

---

<div class="post-metadata">

**Author:** ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.nodered.org/u/blob)\
**Post date:** [23 April 2024 12:17 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/7 "2024-04-23T12:17:45Z")

</div>

Fortunately, I had a back up of the entire pi I had taken then, when the pi was working fine and when the script was created. The very immediate thing I did was, I replaced the SD card of the pi with the old one (back up) and my flow again started working like the original one.

Another work around was (still workable with the updated version) - which is a neater one, is that, I changed the Java script to Type script and replaced the code which was showing errors and it again started working fine.

But I preferred the former approach as it has been working fine for years, so I stick with the older version.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 April 2024 12:29 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/8 "2024-04-23T12:29:45Z")

</div>

> [@blob](#):
>
> But I preferred the former approach as it has been working fine for years, so I stick with the older version

That is, imho, the wrong approach for many reasons not least potential CVEs and recent editor improvements.

As I said before, you can disable the type checking telling you your code is poorly written and it won't bug you to improve it any more. Oh, and I'm case it wasn't clear before, you didn't actually even need to change the code. It runs in the runtime perfectly fine even with the linting errors you are being shown in the editor.

---

<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:** [22 July 2024 12:29 UTC](https://discourse.nodered.org/t/my-old-flow-shows-errors-after-update/87341/9 "2024-07-22T12:29:55Z")

</div>

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