Skip to content

Commit

Permalink
fix(connect): fix device hanged after initial getFeatures timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mroz22 committed Jan 22, 2025
1 parent 7704090 commit bc385c2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/connect/src/device/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { checkFirmwareRevision } from './checkFirmwareRevision';
import { IStateStorage } from './StateStorage';
import type { PromptCallback } from './prompts';
import { calculateFirmwareHash, getBinaryOptional, stripFwHeaders } from '../api/firmware';

import { cancelPrompt } from './prompts';
// custom log
const _log = initLog('Device');

Expand Down Expand Up @@ -555,10 +555,11 @@ export class Device extends TypedEmitter<DeviceEvents> {
// set the timeout for this call so whenever it happens "unacquired device" will be created instead
// next time device should be called together with "Initialize" (calling "acquireDevice" from the UI)
new Promise((_resolve, reject) => {
getFeaturesTimeoutId = setTimeout(
() => reject(new Error('GetFeatures timeout')),
getFeaturesTimeout,
);
getFeaturesTimeoutId = setTimeout(() => {
cancelPrompt(this, false).finally(() => {
reject(new Error('GetFeatures timeout'));
});
}, getFeaturesTimeout);
}),
]);
}
Expand Down

0 comments on commit bc385c2

Please sign in to comment.