# Possible bug with node.status method

**URL:** <https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890>\
**Category:** Developing Nodes\
**Created:** [15 March 2022 15:36 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890 "2022-03-15T15:36:06Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [15 March 2022 15:36 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/1 "2022-03-15T15:36:06Z")

</div>

I change `node.status` based on the emitted event as seen below:

> const STOPSCAN = () =\> {  
> node.status( { fill: "red", shape: "dot", text: "Scan stopped." } );  
> node.log("ding ding")  
> };  
> noble.on('scanStop', STOPSCAN);

I am sure the event is emitted as I see **"ding ding"** in log, but the status of my node is staying same.  
What might be the reason?

---

<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:** [15 March 2022 16:52 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/2 "2022-03-15T16:52:16Z")

</div>

Try refreshing your browser.

Also, try a non arrow function.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [15 March 2022 17:19 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/3 "2022-03-15T17:19:14Z")

</div>

Sadly none of them worked.

One lead might be that the event is emitted via another node. But, why should it matter, because 100%, the event is emitted as I confirm via log.

---

<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:** [15 March 2022 17:20 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/4 "2022-03-15T17:20:41Z")

</div>

Is your repo public? Can you show me it?

What version of node-red are you using?

Have you tried other browser?

Is the `node` object in scope the one you are addressing (use temp flags & console.log or use `debugger` statement to halt inside `STOPSCAN` - inspect the `node` object, are you certain it is the one you think it is?

Lastly, try changing the text for the status (and the fill etc)

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [16 March 2022 09:21 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/5 "2022-03-16T09:21:32Z")

</div>

Hi @Steve-Mcl,

Yes it is public: [GitHub - hkayann/node-red-contrib-ble-sense: Node-RED module for Bluetooth Low Energy (BLE) devices.](https://github.com/hkayann/node-red-contrib-ble-sense)

Node-RED version: `v2.2.2`

Yes, I am sure that it is that `node` object.

Another browser, and changing the status properties did not work either.

Maybe something is wrong with my code.

---

<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:** [16 March 2022 10:03 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/6 "2022-03-16T10:03:51Z")

</div>

Out of pure interest, would you try changing all your arrow functions like this...

```auto

        function STARTSCAN () {
            console.log("scanStart", node, node.status);
            node.status( { fill: "green", shape: "ring", text: "Scanning." } )
        };
        function STOPSCAN () {
            console.log("scanStop", node, node.status);
            node.status( { fill: "red", shape: "dot", text: "Scan stopped." } );
        };

        noble.on('scanStop', function() {
            STOPSCAN();
        });
        noble.on('scanStart', function() {
            STARTSCAN();
        });

```

Restart node-red and browser & inspect the console for scanStart & scanStop messages. Expand the node props & inspect those.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [16 March 2022 16:28 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/7 "2022-03-16T16:28:42Z")

</div>

The error persists. Here is the log:

```auto
scanStop BLEScanner {
  id: '9e287b57697e5114',
  type: 'BLE Scanner',
  z: 'e7ac228a8e11425a',
  g: undefined,
  _closeCallbacks: [],
  _inputCallback: [Function: INPUT],
  _inputCallbacks: null,
  name: 'BLE Scanner',
  wires: [[ '27f5a4ee05adccbf'] ],
  _wireCount: 1,
  send: [Function (anonymous)],
  _wire: '27f5a4ee05adccbf',
  searchFor: 'Feath',
  output: 'Peripheral'
} [Function (anonymous)]
scanStart BLEScanner {
  id: '9e287b57697e5114',
  type: 'BLE Scanner',
  z: 'e7ac228a8e11425a',
  g: undefined,
  _closeCallbacks: [],
  _inputCallback: [Function: INPUT],
  _inputCallbacks: null,
  name: 'BLE Scanner',
  wires: [[ '27f5a4ee05adccbf'] ],
  _wireCount: 1,
  send: [Function (anonymous)],
  _wire: '27f5a4ee05adccbf',
  searchFor: 'Feath',
  output: 'Peripheral'
}

```

I think we have another lead. For some reason, after the following line, It seems like `scanStart` event is emitted.

```auto
await noble.stopScanningAsync().catch(e => send(e));

```

I am pretty sure the **Bluetooth** adapter stops scanning as Bluetooth debugger shows no event. So, I feel like this might be bug of `@abandonware/noble`.

---

<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:** [16 March 2022 17:32 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/8 "2022-03-16T17:32:16Z")

</div>

> [@hkayan](#):
>
> `await noble.stopScanningAsync().catch(e => send(e));`

You have promises and async await syntax intermixed there.

surely that should be either

```auto
noble.stopScanningAsync()
 .then(e => {send(e);})
 .catch(err => {done(err)})

```

or

```auto
try {
  var e = await noble.stopScanningAsync()
  send(e)
} catch(err) {
  done(err)
}

```

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [18 March 2022 11:09 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/9 "2022-03-18T11:09:34Z")

</div>

> [@Steve-Mcl](#):
>
> ```auto
> try {
> var e = await noble.stopScanningAsync()
> send(e)
> } catch(err) {
> done(err)
> }
> 
> ```

Thank you. I fixed them all but sadly the error still persists. For some reason `scanStart` event is emitted even though the adapter is not scanning.

---

<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:** [18 March 2022 11:22 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/10 "2022-03-18T11:22:47Z")

</div>

Sorry, I'm a bit lost off now.

What error?

Is the status update now working?

Can you clarify with a bit more details please?

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [18 March 2022 11:41 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/11 "2022-03-18T11:41:48Z")

</div>

Hi @Steve-Mcl,

The status update is working. The problem seems like with the `@abandonware/noble` package.

Here is my example setup.  
 ![setupNodeRED](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/73bd4c53aa025b8fe046d31a1e33b7bfe3da1dec.png)  
After BLE device is connected, I expect `BLE Scanner` status to show `Scan stopped`.

```auto
function STOPSCAN () {
  console.log("scanStop", node, node.status);
  node.status( { fill: "red", shape: "dot", text: "Scan stopped." } );
};
noble.on('scanStop', function() {
  STOPSCAN();
});

```

But for some reason, the `scanStart` event is emitted as I can see it on log even though the adapter is not scanning.

Hence the status shows `Scanning`. I opened an issue on their GitHub as well.

---

<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:** [18 March 2022 11:53 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/12 "2022-03-18T11:53:25Z")

</div>

ok, so we can safely say, the title "Possible bug with node.status" is now proven to be false yeah?

I guess you will have to wait for feedback on the noble package or start digging into it yourself.

---

<div class="post-metadata">

**Author:** ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)\
**Post date:** [18 March 2022 11:55 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/13 "2022-03-18T11:55:00Z")

</div>

Yes exactly. Thanks for the help.

---

<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:** [1 April 2022 11:55 UTC](https://discourse.nodered.org/t/possible-bug-with-node-status-method/59890/14 "2022-04-01T11:55:48Z")

</div>

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