Skip to content

Commit 434f9c5

Browse files
committed
fix(connect): flush device with Cancel command on first interaction to prevent unexpected messages being read
1 parent 697615e commit 434f9c5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/connect/src/device/Device.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -532,17 +532,21 @@ export class Device extends TypedEmitter<DeviceEvents> {
532532
await this.acquire();
533533
}
534534

535+
const getFeaturesTimeout =
536+
DataManager.getSettings('env') === 'react-native'
537+
? GET_FEATURES_TIMEOUT_REACT_NATIVE
538+
: GET_FEATURES_TIMEOUT;
539+
535540
const { staticSessionId, deriveCardano } = this.getState() || {};
536541
if (acquireNeeded || !staticSessionId || (!deriveCardano && options.useCardanoDerivation)) {
537542
// update features
538543
try {
539544
if (fn) {
540545
await this.initialize(!!options.useCardanoDerivation);
541546
} else {
542-
const getFeaturesTimeout =
543-
DataManager.getSettings('env') === 'react-native'
544-
? GET_FEATURES_TIMEOUT_REACT_NATIVE
545-
: GET_FEATURES_TIMEOUT;
547+
_log.debug('sending cancel');
548+
await cancelPrompt(this, true).catch(() => {});
549+
_log.debug('sending cancel done');
546550

547551
let getFeaturesTimeoutId: ReturnType<typeof setTimeout> | undefined;
548552

0 commit comments

Comments
 (0)