Skip to content

Commit

Permalink
fix(connect): longer timeout for getFeatures due to suite-native perf…
Browse files Browse the repository at this point in the history
…ormance issue

- During app start of Suite Lite, get features could takes longer than 3s depending on view-only wallets and the phone. This is a workaround for now, we should investigate why it takes so long.
- fixes #13456
  • Loading branch information
matejkriz committed Aug 1, 2024
1 parent a4a196f commit 0910ab7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/connect/src/device/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DeviceCommands, PassphrasePromptResponse } from './DeviceCommands';
import { PROTO, ERRORS, NETWORK } from '../constants';
import { DEVICE, DeviceButtonRequestPayload, UI } from '../events';
import { getAllNetworks } from '../data/coinInfo';
import { DataManager } from '../data/DataManager';
import { getFirmwareStatus, getRelease } from '../data/firmwareInfo';
import {
parseCapabilities,
Expand Down Expand Up @@ -50,7 +51,9 @@ export type RunOptions = {
useCardanoDerivation?: boolean;
};

export const GET_FEATURES_TIMEOUT = 3000;
export const GET_FEATURES_TIMEOUT = 3_000;
// Due to performance issues in suite-native during app start, original timeout is not sufficient.
export const GET_FEATURES_TIMEOUT_REACT_NATIVE = 20_000;

const parseRunOptions = (options?: RunOptions): RunOptions => {
if (!options) options = {};
Expand Down Expand Up @@ -338,6 +341,11 @@ export class Device extends TypedEmitter<DeviceEvents> {
if (fn) {
await this.initialize(!!options.useCardanoDerivation);
} else {
const getFeaturesTimeout =
DataManager.getSettings('env') === 'react-native'
? GET_FEATURES_TIMEOUT_REACT_NATIVE
: GET_FEATURES_TIMEOUT;

// do not initialize while firstRunPromise otherwise `features.session_id` could be affected
await Promise.race([
this.getFeatures(),
Expand All @@ -351,7 +359,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
new Promise((_resolve, reject) =>
setTimeout(
() => reject(new Error('GetFeatures timeout')),
GET_FEATURES_TIMEOUT,
getFeaturesTimeout,
),
),
]);
Expand Down
1 change: 1 addition & 0 deletions suite-native/state/src/extraDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const extraDependencies: ExtraDependencies = mergeDeepObject(extraDepende
lazyLoad: false,
transportReconnect: false,
debug: false,
env: 'react-native',
popup: false,
manifest: {
email: '[email protected]',
Expand Down

0 comments on commit 0910ab7

Please sign in to comment.