Unhandled Promise Rejection

Supporting Browser-based Javascript and Node.js
Posts: 34
Joined: Wed Jul 17, 2019 9:28 am

Unhandled Promise Rejection

Postby AdamLee » Wed Jul 22, 2020 3:20 pm

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.
Adam Lee
Software Engineer

Fresh meat
Posts: 1
Joined: Wed Sep 02, 2020 7:44 am

Re: Unhandled Promise Rejection

Postby arpadsooky » Wed Sep 02, 2020 7:46 am

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


Fresh meat
Posts: 1
Joined: Tue Oct 06, 2020 6:58 am

Re: Unhandled Promise Rejection

Postby ruisebastiao » Tue Oct 06, 2020 6:59 am

you have to handle/catch the promise errors:

Code: Select all

conn.connect().then(runExample).catch((error) => {

Return to “Javascript”

Who is online

Users browsing this forum: No registered users and 2 guests