# Best practice for use of Done and Error

**URL:** <https://discourse.nodered.org/t/best-practice-for-use-of-done-and-error/39063>\
**Category:** Developing Nodes\
**Created:** [13 January 2021 15:00 UTC](https://discourse.nodered.org/t/best-practice-for-use-of-done-and-error/39063 "2021-01-13T15:00:55Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [13 January 2021 16:32 UTC](https://discourse.nodered.org/t/best-practice-for-use-of-done-and-error/39063/6 "2021-01-13T16:32:28Z")

</div>

Just to keep in mind that’s the new way that is not backwards compatible. Pre 1.0 or 1.2 compatibility would mean to use something like:

```auto
(done) ? done(err) : node.error(err);

```

As those older nodered versions don’t have the done function and in the new functions you should only call `node.error()` if for some reason you already called `done()` and an error happens afterwards for example in the on close function or doing async work.  
At least that’s how I understand it.

Edit:  
I also previously had the discussion when to call done in some edge cases here:

> [@Use of msg, send, done in node that can also be triggered by button & more than one input msg to one logical process, when to call done?](https://discourse.nodered.org/t/use-of-msg-send-done-in-node-that-can-also-be-triggered-by-button-more-than-one-input-msg-to-one-logical-process-when-to-call-done/28934):
>
> Hello, little question here: For my sox record node i have the option that the user can choose whether to start recording on an input message or have no input but a button like the inject node instead to start and stop. So i just started implementing the 1.0 things like using send and done to tell the runtime when the node is done recording. So my question is do i somehow have access to the done function when the node was started with the button? As now the record function gets called from the…

---

_[View the full topic](https://discourse.nodered.org/t/best-practice-for-use-of-done-and-error/39063)._
