# Unhandled Promise Rejection Warning

**URL:** https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405
**Category:** General
**Created:** [28 November 2021 16:37 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405 "2021-11-28T16:37:18Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [28 November 2021 16:37 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/1 "2021-11-28T16:37:18Z")

</div>

In terminal I have this error:

(node:1946) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see [Command-line options | Node.js v17.1.0 Documentation](https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode)). (rejection id: 1)  
(node:1946) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I think the problem is this function (It's not my function) because is the only async function I have,

```auto
async function delay(timeMs) {
  await new Promise(resolve => setTimeout(resolve, timeMs));
} 
var newInit = msg.payload;
var oldInit = global.get("alexa");
if (newInit != oldInit)
{
 global.set("alexa", msg.payload); 
 msg.payload="refresh";
 await delay(20000);  
 return msg;
}

```

Can you help me to fix the error?

---

<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: [28 November 2021 18:29 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/2 "2021-11-28T18:29:53Z")

</div>

Is this about creating a custom node for Node-RED? If not, could you please change the category to "General"? Thanks.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [28 November 2021 19:00 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/3 "2021-11-28T19:00:58Z")

</div>

Ok, and now you can help me?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 November 2021 20:20 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/4 "2021-11-28T20:20:30Z")

</div>

Can you share the full stack trace of the error?

I can't immediately see how the code you've shared could throw an error.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [28 November 2021 20:34 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/5 "2021-11-28T20:34:24Z")

</div>

Please tell me what to do ....  
I saw this error not in node-red but in the terminal of Raspberry after start node-red ...

```auto
28 Nov 15:58:53 - [info] Dashboard version 3.1.2 started at /ui
(node:1946) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir '/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/examples'
(node:1946) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1946) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

```

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 November 2021 20:48 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/6 "2021-11-28T20:48:27Z")

</div>

I would change the function to not use promises:

```auto
var newInit = msg.payload;
var oldInit = global.get("alexa");
if (newInit != oldInit)
{
 global.set("alexa", msg.payload); 
 msg.payload="refresh";
 setTimeout(()=>{ node.send(msg) }, 20000)
}

```

If you still get the error, then it's coming from somewhere else.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [28 November 2021 21:05 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/7 "2021-11-28T21:05:51Z")

</div>

Now I saw this:

```auto
(node:1738) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir '/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/examples'
(node:1738) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1738) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

```

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 November 2021 21:20 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/8 "2021-11-28T21:20:38Z")

</div>

That is a strange error to get - the directory should absolutely exist.

How did you install Node-RED?

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [28 November 2021 21:29 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/9 "2021-11-28T21:29:52Z")

</div>

On Raspberry Pi4 with this instruction:

```auto
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [28 November 2021 21:59 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/10 "2021-11-28T21:59:42Z")

</div>

Wrong instructions. That is very old I think. See [Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi)

**[Edit]** When you ran that it should have told you where the one to use is.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [29 November 2021 08:44 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/11 "2021-11-29T08:44:18Z")

</div>

Sorry ...  
you must have patience with me because I'm not young anymore and sometimes I struggle to follow you ....

I wrote one wrong thing and yes, to install node red I followed "Running on Raspberry Pi : Node-RED".

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [29 November 2021 10:18 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/12 "2021-11-29T10:18:56Z")

</div>

OK. Does the folder mentioned in the error message exist? If not then follow the path down (/usr/lib/node\_modules, then the next level down and so on), and see where it stops.

Also could you stop node red and start it again in a terminal and post the full startup log please.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [29 November 2021 10:57 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/13 "2021-11-29T10:57:30Z")

</div>

Yes, the folder mentioned exist ...  
For information, in the node red setting.js I have:  
. change uiPort  
. set a httpStatic  
. set adminAuth with username and password  
. set httpNodeAuth with username and password

My project works for a few months without big problems excluded object detection with tfjs-coco-ssd after update to the new version (palette) don't work ...

This is the log:

```auto
pi@raspberrypi:~ $ node-red
29 Nov 11:41:09 - [info] 

Welcome to Node-RED
===================

29 Nov 11:41:09 - [info] Node-RED version: v1.3.4
29 Nov 11:41:09 - [info] Node.js version: v12.22.0
29 Nov 11:41:09 - [info] Linux 5.10.63-v7l+ arm LE
29 Nov 11:41:09 - [info] Loading palette nodes
SmartthingsConfigNode
29 Nov 11:41:14 - [info] Dashboard version 3.1.2 started at /ui
29 Nov 11:41:15 - [info] Settings file : /home/pi/.node-red/settings.js
29 Nov 11:41:15 - [info] HTTP Static : /home/pi/imgcam
29 Nov 11:41:15 - [info] Context store : 'default' [module=memory]
29 Nov 11:41:15 - [info] User directory : /home/pi/.node-red
29 Nov 11:41:15 - [warn] Projects disabled : editorTheme.projects.enabled=false
29 Nov 11:41:15 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
(node:21636) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir '/usr/lib/node_modules/node-red/node_modules/@node-red/nodes/examples'
(node:21636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:21636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
29 Nov 11:41:15 - [info] Server now running at http://127.0.0.1:1968/admin/
29 Nov 11:41:15 - [warn] 

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

29 Nov 11:41:16 - [info] Starting flows
SmartthingsConfigNode
{
  id: 'ba51a982.2707b8',
  type: 'smartthings-config',
  name: 'SmartNode',
  token: '9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4',
  _users: [
    '9376f12d.2f3d5',
    '4c9fb70e.8e7738',
    '785b68e3.e42738',
    'd8485848.f1c9f8',
    '627df546.e67e84',
    '3f1abca.9f608c4',
    '41d43139.c912b',
    '6a8a9c0a.e357ac'
  ]
}
SmartthingsConfigNode called
SmartthingsButtonNode
SmartthingsOnOffNode
{
  id: '6a8a9c0a.e357ac',
  type: 'smartthings-node-onoff',
  z: '449216f2.c5187',
  conf: 'ba51a982.2707b8',
  name: 'Vimar Switch 01',
  device: 'f8c9731c-ad60-43b6-8a9d-e88070e32d18',
  x: 1550,
  y: 1220,
  wires: [[ '8d540987.c56ac8'] ]
}
getDeviceStatus:token:9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
Request::
url: https://api.smartthings.com/v1/devices/f8c9731c-ad60-43b6-8a9d-e88070e32d18/components/main/capabilities/switch/status
method: GET
json: true
headers: 
  Authorization: Bearer 9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
qs: 
body: 

SmartthingsButtonNode
SmartthingsMotionNode
{
  id: '9376f12d.2f3d5',
  type: 'smartthings-node-motion',
  z: '348ee176.f8584e',
  conf: 'ba51a982.2707b8',
  name: 'Aeotec Multisensor',
  device: '1d922164-ddfa-47c2-bb57-71355d892794',
  x: 110,
  y: 740,
  wires: [[ '2f1c9388.36a54c'] ]
}
getDeviceStatus:token:9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
Request::
url: https://api.smartthings.com/v1/devices/1d922164-ddfa-47c2-bb57-71355d892794/components/main/capabilities/motionSensor/status
method: GET
json: true
headers: 
  Authorization: Bearer 9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
qs: 
body: 

Platform node has already been set. Overwriting the platform with [object Object].
29 Nov 11:41:17 - [error] [tensorflowCoco:8779f7a.f0b0388] TypeError: Cannot read property 'whereImpl' of undefined
SmartthingsOnOffNode
{
  id: 'd8485848.f1c9f8',
  type: 'smartthings-node-onoff',
  z: '545b2d85.6c6f64',
  conf: 'ba51a982.2707b8',
  name: 'Aeotec Outlet A',
  device: '4b408ac3-33fb-4e89-ad1a-430d3b570b9c',
  x: 180,
  y: 1140,
  wires: [[ '559279e6.6028c8'] ]
}
getDeviceStatus:token:9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
Request::
url: https://api.smartthings.com/v1/devices/4b408ac3-33fb-4e89-ad1a-430d3b570b9c/components/main/capabilities/switch/status
method: GET
json: true
headers: 
  Authorization: Bearer 9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
qs: 
body: 

SmartthingsOnOffNode
{
  id: '627df546.e67e84',
  type: 'smartthings-node-onoff',
  z: '545b2d85.6c6f64',
  conf: 'ba51a982.2707b8',
  name: 'Aeotec Outlet L',
  device: 'daeb89ed-dd8a-47a6-b5ba-2e84e5dc1a87',
  x: 180,
  y: 1400,
  wires: [[ 'fb76cf9e.0a114'] ]
}
getDeviceStatus:token:9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
Request::
url: https://api.smartthings.com/v1/devices/daeb89ed-dd8a-47a6-b5ba-2e84e5dc1a87/components/main/capabilities/switch/status
method: GET
json: true
headers: 
  Authorization: Bearer 9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
qs: 
body: 

SmartthingsOnOffNode
{
  id: '3f1abca.9f608c4',
  type: 'smartthings-node-onoff',
  z: '545b2d85.6c6f64',
  conf: 'ba51a982.2707b8',
  name: 'Frient Plug smart 2',
  device: '65547a82-4cfa-45a7-a456-ff92d4ce4dbe',
  x: 190,
  y: 420,
  wires: [[ '767a0f3f.bce6c'] ]
}
getDeviceStatus:token:9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
Request::
url: https://api.smartthings.com/v1/devices/65547a82-4cfa-45a7-a456-ff92d4ce4dbe/components/main/capabilities/switch/status
method: GET
json: true
headers: 
  Authorization: Bearer 9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
qs: 
body: 

SmartthingsOnOffNode
{
  id: '41d43139.c912b',
  type: 'smartthings-node-onoff',
  z: '545b2d85.6c6f64',
  conf: 'ba51a982.2707b8',
  name: 'Frient Plug smart',
  device: '79d3a792-df0a-4ace-8874-c2da54e06d35',
  x: 190,
  y: 900,
  wires: [[ '71bbdc04.73132c'] ]
}
getDeviceStatus:token:9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
Request::
url: https://api.smartthings.com/v1/devices/79d3a792-df0a-4ace-8874-c2da54e06d35/components/main/capabilities/switch/status
method: GET
json: true
headers: 
  Authorization: Bearer 9fccaea8-a4f9-475a-8dd3-e73f8bc32ae4
qs: 
body: 

29 Nov 11:41:18 - [info] Started flows
29 Nov 11:41:19 - [info] [mqtt-broker:MyMQTT] Connected to broker: mqtt://localhost:1883
29 Nov 11:41:19 - [info] [alexa-remote-account:MyAlexa] intialising "MyAlexa" with the PROXY method and saved data...
29 Nov 11:41:19 - [info] [deconz-server:Phoscon] WebSocket opened
Device Status (daeb89ed-dd8a-47a6-b5ba-2e84e5dc1a87):
{ switch: { value: 'off', timestamp: '2021-11-29T06:52:58.381Z' } }
Device Status (4b408ac3-33fb-4e89-ad1a-430d3b570b9c):
{ switch: { value: 'off', timestamp: '2021-11-29T08:33:59.017Z' } }
Device Status (f8c9731c-ad60-43b6-8a9d-e88070e32d18):
{ switch: { value: 'off', timestamp: '2021-11-28T12:39:09.856Z' } }
Device Status (1d922164-ddfa-47c2-bb57-71355d892794):
{
  motion: { value: 'inactive', timestamp: '2021-11-29T09:28:21.609Z' }
}
OnOffDevice(Aeotec Outlet L) Status Refreshed
OnOffDevice(Aeotec Outlet A) Status Refreshed
OnOffDevice(Vimar Switch 01) Status Refreshed
MotionDevice(Aeotec Multisensor) Status Refreshed
{
  motion: { value: 'inactive', timestamp: '2021-11-29T09:28:21.609Z' }
}
Device Status (79d3a792-df0a-4ace-8874-c2da54e06d35):
{ switch: { value: 'off', timestamp: '2021-11-22T12:25:16.449Z' } }
Device Status (65547a82-4cfa-45a7-a456-ff92d4ce4dbe):
{ switch: { value: 'off', timestamp: '2021-11-22T08:09:52.166Z' } }
OnOffDevice(Frient Plug smart) Status Refreshed
OnOffDevice(Frient Plug smart 2) Status Refreshed
29 Nov 11:41:22 - [info] [alexa-remote-account:MyAlexa] intialising "MyAlexa" with the PROXY method and saved data...
29 Nov 11:41:25 - [error] [alexa-remote-account:MyAlexa] Initialisation was aborted!
29 Nov 11:41:48 - [info] [alexa-remote-account:MyAlexa] intialising "MyAlexa" with the PROXY method and saved data...

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [29 November 2021 11:05 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/14 "2021-11-29T11:05:06Z")

</div>

> [@Giamma](#):
>
> after update to the new version (palette) don't work

What did you upgrade and what doesn't work?

> [@Giamma](#):
>
> `[error] [tensorflowCoco:8779f7a.f0b0388] TypeError: Cannot read property 'whereImpl' of undefined`

As far as I can see that is the only error there.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [29 November 2021 11:14 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/15 "2021-11-29T11:14:04Z")

</div>

I updated the palette node-red-contrib-tfjs-coco-ssd to the new release 1.0.1.  
After update I have that error and the detection object don't works.  
I noticed that the node tfjs-coco-ssd don't load the model .....

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [29 November 2021 11:27 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/16 "2021-11-29T11:27:27Z")

</div>

OK, probably best to submit an issue on the node's github page.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [29 November 2021 11:31 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/17 "2021-11-29T11:31:11Z")

</div>

OK, and thank you ...

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [29 November 2021 11:35 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/18 "2021-11-29T11:35:08Z")

</div>

After submitting the issue, if you want to go back to the previous version, go into your .node-red folder and run  
`npm install node-red-contrib-tjfs-coco-ssd@1.0.0`  
assuming 1.0.0 was the previous version. Then restart node red.

---

<div class="post-metadata">

### Author: ![Giamma](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@Giamma](https://discourse.nodered.org/u/Giamma)
#### Post date: [29 November 2021 11:55 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/19 "2021-11-29T11:55:14Z")

</div>

I'll make some test, thank you 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: [28 January 2022 11:55 UTC](https://discourse.nodered.org/t/unhandled-promise-rejection-warning/54405/20 "2022-01-28T11:55:56Z")

</div>

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