Unhandled Promise Rejection Warning

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). (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,

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?

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

Ok, and now you can help me?

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.

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

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.

I would change the function to not use promises:

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.

Now I saw this:

(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.

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

How did you install Node-RED?

On Raspberry Pi4 with this instruction:

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

Wrong instructions. That is very old I think. See Running on Raspberry Pi : Node-RED

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

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".

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.

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:

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...



What did you upgrade and what doesn't work?

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

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 .....

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

OK, and thank you ...

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.

I'll make some test, thank you again ....

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