@@ -91,6 +91,10 @@ export const MNEMONICS = {
9191
9292export const DEFAULT_BRIDGE_VERSION = '2.0.33' ;
9393
94+ // There's an ongoing problem with debug link & button requests race conditions
95+ // Adding a delay to workaround this issue temporarily
96+ const EMU_RACE_CONDITION_WORKAROUND_DELAY = 50 ;
97+
9498export class TrezorUserEnvLinkClass extends TypedEmitter < WebsocketClientEvents > {
9599 private client : WebsocketClient ;
96100 public firmwares ?: Firmwares ;
@@ -247,41 +251,49 @@ export class TrezorUserEnvLinkClass extends TypedEmitter<WebsocketClientEvents>
247251 return null ;
248252 }
249253 async pressYes ( ) {
254+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
250255 await this . client . send ( { type : 'emulator-press-yes' } ) ;
251256
252257 return null ;
253258 }
254259 async pressNo ( ) {
260+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
255261 await this . client . send ( { type : 'emulator-press-no' } ) ;
256262
257263 return null ;
258264 }
259265 async swipeEmu ( direction : 'up' | 'down' | 'left' | 'right' ) {
266+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
260267 await this . client . send ( { type : 'emulator-swipe' , direction } ) ;
261268
262269 return null ;
263270 }
264271 async inputEmu ( value : string ) {
272+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
265273 await this . client . send ( { type : 'emulator-input' , value } ) ;
266274
267275 return null ;
268276 }
269277 async clickEmu ( options : ClickEmu ) {
278+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
270279 await this . client . send ( { type : 'emulator-click' , ...options } ) ;
271280
272281 return null ;
273282 }
274283 async resetDevice ( options : any ) {
284+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
275285 await this . client . send ( { type : 'emulator-reset-device' , ...options } ) ;
276286
277287 return null ;
278288 }
279289 async readAndConfirmMnemonicEmu ( ) {
290+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
280291 await this . client . send ( { type : 'emulator-read-and-confirm-mnemonic' } ) ;
281292
282293 return null ;
283294 }
284295 async readAndConfirmShamirMnemonicEmu ( options : ReadAndConfirmShamirMnemonicEmu ) {
296+ await new Promise ( resolve => setTimeout ( resolve , EMU_RACE_CONDITION_WORKAROUND_DELAY ) ) ;
285297 await this . client . send ( {
286298 type : 'emulator-read-and-confirm-shamir-mnemonic' ,
287299 ...options ,
0 commit comments