Skip to content

Commit

Permalink
Shorten the timeout for device-info query (#525)
Browse files Browse the repository at this point in the history
* Shorten the timeout for device-info query

* Show loading statusbar item when fetching device-info

* Fix broken tests
  • Loading branch information
TwitchBronBron authored Nov 13, 2023
1 parent d816cce commit 69ff77d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/DebugConfigurationProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,16 @@ describe('BrightScriptConfigurationProvider', () => {
expect(config.remotePort).to.equal(5678);
});

[
{ input: true, expected: { activateOnSessionStart: true, deactivateOnSessionEnd: true } },
{ input: false, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } },
{ input: undefined, expected: { activateOnSessionStart: false, deactivateOnSessionEnd: false } }
].forEach(({ input, expected }) => {
it('allows using a bool value for remoteConfigMode', async () => {
it('allows using a bool value for remoteConfigMode', async () => {
async function doTest(remoteControlMode: boolean, expected: any) {
let config = await configProvider.resolveDebugConfiguration(folder, <any>{
remoteControlMode: input
remoteControlMode: remoteControlMode
});
expect(config.remoteControlMode).to.deep.equal(expected);
});
}
await doTest(true, { activateOnSessionStart: true, deactivateOnSessionEnd: true });
await doTest(false, { activateOnSessionStart: false, deactivateOnSessionEnd: false });
await doTest(undefined, { activateOnSessionStart: false, deactivateOnSessionEnd: false });
});
});

Expand Down
6 changes: 5 additions & 1 deletion src/DebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,16 @@ export class BrightScriptDebugConfigurationProvider implements DebugConfiguratio
result = await this.processDeepLinkUrlParameter(result);
result = await this.processLogfilePath(folder, result);

const statusbarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 9_999_999);
statusbarItem.text = '$(sync~spin) Fetching device info';
statusbarItem.show();
try {
deviceInfo = await rokuDeploy.getDeviceInfo({ host: result.host, remotePort: result.remotePort, enhance: true });
deviceInfo = await rokuDeploy.getDeviceInfo({ host: result.host, remotePort: result.remotePort, enhance: true, timeout: 4000 });
} catch (e) {
// a failed deviceInfo request should NOT fail the launch
console.error(`Failed to fetch device info for ${result.host}`, e);
}
statusbarItem.dispose();

if (deviceInfo && !deviceInfo.developerEnabled) {
throw new Error(`Cannot deploy: developer mode is disabled on '${result.host}'`);
Expand Down
3 changes: 2 additions & 1 deletion src/mockVscode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export let vscode = {
return {
clear: () => { },
text: '',
show: () => { }
show: () => { },
dispose: () => { }
};
},
createQuickPick: () => {
Expand Down

0 comments on commit 69ff77d

Please sign in to comment.