Skip to content

Commit

Permalink
fix(connect): flush device with Cancel command on first interaction t…
Browse files Browse the repository at this point in the history
…o prevent unexpected messages being read
  • Loading branch information
mroz22 committed Jan 24, 2025
1 parent 5c06872 commit 8ce9c9b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/connect/src/device/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,21 @@ export class Device extends TypedEmitter<DeviceEvents> {
await this.acquire();
}

const getFeaturesTimeout =
DataManager.getSettings('env') === 'react-native'
? GET_FEATURES_TIMEOUT_REACT_NATIVE
: GET_FEATURES_TIMEOUT;

const { staticSessionId, deriveCardano } = this.getState() || {};
if (acquireNeeded || !staticSessionId || (!deriveCardano && options.useCardanoDerivation)) {
// update features
try {
if (fn) {
await this.initialize(!!options.useCardanoDerivation);
} else {
const getFeaturesTimeout =
DataManager.getSettings('env') === 'react-native'
? GET_FEATURES_TIMEOUT_REACT_NATIVE
: GET_FEATURES_TIMEOUT;
_log.debug('sending cancel');
await cancelPrompt(this, true).catch(() => {});
_log.debug('sending cancel done');

let getFeaturesTimeoutId: ReturnType<typeof setTimeout> | undefined;

Expand Down

0 comments on commit 8ce9c9b

Please sign in to comment.