# Fix nodes that aren't broken?

**URL:** <https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644>\
**Category:** Developing Nodes\
**Created:** [28 September 2021 20:15 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644 "2021-09-28T20:15:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [28 September 2021 20:15 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/1 "2021-09-28T20:15:06Z")

</div>

I am doing some maintenance and renovation work on nodes I published long ago, about the time of NR version 0.17. I wonder whether it would be worthwhile to update the JS file to use the features introduced in version 1.0, in particular, the new `input` listener with `send` and `done` functions. I obviously would have to avoid breaking compatibility with earlier versions of NR. Are there other changes worth making?

---

<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:** [28 September 2021 21:57 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/2 "2021-09-28T21:57:10Z")

</div>

Maybe nothing that _needs_ doing but things I do when I go back and update old nodes...

- Add example flows for CTRL+I examples import
- Improve built in docs & add reference to there being built in examples
- Ensure elements in the edit form expand correctly as the edit form expands using style "width: calc(100% - 120px)"
- If you have an ACE editor on the edit form, make sure you call the correct API instead of accessing ACE directly
- Change any override-able inputs with typedInputs
- Add a "Returns to msg.\_\_\_\_" so that the user can avoid having to add change nodes after you node to move the payload into a different area of the msg when performing several serial actions.

Note, none of the above are necessary but I have found they make for very useful user enhancements.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 September 2021 22:28 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/3 "2021-09-28T22:28:59Z")

</div>

Quite a few of the the extra nodes we ship do now have done and complete added in a non breaking way so it is good if you can add those as you go forwards.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 September 2021 00:39 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/4 "2021-09-29T00:39:41Z")

</div>

> [@drmibell](#):
>
> Are there other changes worth making?

Obviously update any dependent packages, I do this as a matter of course before publishing a new version of my nodes. I also use an add-in action on GitHub that lets me know (and even creates an automatic PR) if there are dependencies that should be updated.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [29 September 2021 03:30 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/5 "2021-09-29T03:30:43Z")

</div>

Thanks. All good suggestions -- most already part of my practice.

I sometimes think that my example flows may be too large/many. I have started omitting their JSON strings from the README, because they fill up the library page and force the reader to keep scrolling to find the end. Of course, that makes it all the more important to point the user to the import menu.

I confess to failing totally when it comes to using the style guide for help text. Most of my text was written before the guide, and there just has not been enough spare time, even during COVID, to invest in re-working it.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [29 September 2021 03:32 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/6 "2021-09-29T03:32:47Z")

</div>

On the job queue, completion date unknown.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [29 September 2021 04:56 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/7 "2021-09-29T04:56:22Z")

</div>

Regarding your question about backward compatibility for the new features of the `input` listener (a.k.a. support for the `complete` node):

This is what I'm doing:

- change the signature from `(msg)` to `(msg, send, done)`
- declare `send` and `done` locally with fall-backs (see below)
- replace your `node.send()` and `node.error()` calls with them
- add the `done()` call in all non-error code paths once you're code is done

Should be it, hope I didn't forget anything. 🤓

```auto
this.on('input', function (msg, send, done) {

    send = send || function () { node.send.apply(node, arguments) };
    done = done || function () { if (arguments.length > 0) { node.error.apply(node, [arguments[0], msg]); } };
    
    send(msg);

    done();

});

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 September 2021 08:12 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/8 "2021-09-29T08:12:48Z")

</div>

As uibuilder now requires Node-RED v1.3 as a minimum, I don't bother with that now. But I use it on other nodes.

---

<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:** [28 November 2021 08:13 UTC](https://discourse.nodered.org/t/fix-nodes-that-arent-broken/51644/9 "2021-11-28T08:13:45Z")

</div>

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