Page 1 of 1

Unhandled Promise Rejection

Posted: Wed Jul 22, 2020 3:20 pm
by AdamLee
I updated our Phidget22 package the other day and now I'm intermittently noticing these:

Code: Select all

(node:15) 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(). (rejection id: 2178)
(node:15) UnhandledPromiseRejectionWarning: Error
   at new Pt (/usr/src/api/node_modules/phidget22/phidget22.min.js:1:13902)
   at Object.onReply (/usr/src/api/node_modules/phidget22/phidget22.min.js:2:17461)
   at Bt.N.Bt.ondatamessage (/usr/src/api/node_modules/phidget22/phidget22.min.js:2:19938)
   at Bt.onmessage (/usr/src/api/node_modules/phidget22/phidget22.min.js:2:15368)
   at Bt.Rt (/usr/src/api/node_modules/phidget22/phidget22.min.js:2:12155)
   at Socket.emit (events.js:198:13)
   at addChunk (_stream_readable.js:288:12)
   at readableAddChunk (_stream_readable.js:269:11)
   at Socket.Readable.push (_stream_readable.js:224:10)
   at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)


Anyone else? I'm having a really hard time tracking down where this is happening since it's asynchronous.

Re: Unhandled Promise Rejection

Posted: Wed Sep 02, 2020 7:46 am
by arpadsooky
Hi,
I have the same error with the example code. Is there any solution?

I use
- node version 11.6.0
- npm version 6.5.1
- phidget22 version 2.6.9

thanks

Re: Unhandled Promise Rejection

Posted: Tue Oct 06, 2020 6:59 am
by ruisebastiao
you have to handle/catch the promise errors:

Code: Select all

conn.connect().then(runExample).catch((error) => {
   console.error("err:"+error)
});