BitBoxSwiss / bitbox02-api-js

BitBox02 JavaScript library
Other
11 stars 9 forks source link

Error after inactivity #66

Open refi93 opened 2 years ago

refi93 commented 2 years ago

Hi, some of our users (https://adalite.io) are reporting getting the following error after some time of inactivity in the app originating from this library:

Error: runtime error: cannot block in JavaScript callback, fix by wrapping code in goroutine
  at $callDeferred(./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:4:22730)
  at $panic(./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:4:23334)
  at AR(./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:8:6488)
  at $block(./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:4:24776)
  at $send(./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:4:25163)
  at Object.push.5824.$packages.bitbox02-api-js.AL.ptr.OnRead(./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:90:39864)
  at Object.e.$externalizeWrapper.e.$externalizeWrapper(./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:4:29372)
  at ? (./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:6:4331)
  at Object.e.$externalizeWrapper.e.$externalizeWrapper [as OnRead](./app/node_modules/bitbox02-api/lib/bitbox02-api-go.js:4:29372)
  at onMessage(./app/node_modules/bitbox02-api/lib/bitbox02.js:391:1)
  at HIDDevice.onInputReport(./app/node_modules/bitbox02-api/lib/bitbox02.js:310:1)

Do you know what can be causing it and how to prevent that from happening? Is that possibly something that needs to be addressed in the library itself?

benma commented 2 years ago

Hi. Just to clarify, this is from users while they use a BitBox02?

refi93 commented 2 years ago

I'm not completely sure as I haven't reproduced it myself and the users didn't leave a way to contact them back but given that we load the library only if the user logs in with their Bitbox02 wallet, I'd suppose so

refi93 commented 2 years ago

Ok, I checked the logs sent alongside the error and from them, it's clear that the user was connected with their Bitbox02 wallet (logged in console the firmware version etc.) .

I also found a way to replicate the issue - it happens when I'm logged with Bitbox02 wallet in one window (via WebHID, so e.g. Google Chrome) and then I try to login in a new tab with the same device. The first window then shows the error reported above. I guess the library shouldn't allow creating a new session while there's an active connection in another window (that's e.g. what Ledger does), or can you suggest a different way to handle it properly?