preload - revert retry logic which does not seem to help

This commit is contained in:
Benjamin Pasero
2022-04-14 08:14:40 +02:00
parent a7a7f209ad
commit 55759234d7
4 changed files with 11 additions and 57 deletions

View File

@@ -9,10 +9,6 @@
const { ipcRenderer, webFrame, contextBridge } = require('electron');
/**
* @typedef {import('../common/sandboxTypes').ISandboxConfiguration} ISandboxConfiguration
*/
//#region Utilities
/**
@@ -53,51 +49,14 @@
return undefined;
}
/**
* @param {string} channel
* @param {number} retryDelay
* @returns {Promise<ISandboxConfiguration>}
*/
async function invokeWithRetry(channel, retryDelay) {
let timeoutHandle;
// A timeout promise that resolves after `retryDelay`
const timeout = new Promise(resolve => {
timeoutHandle = setTimeout(() => {
resolve();
}, retryDelay);
});
// A first `invoke` call that clears the timeout
const firstInvoke = ((async () => {
try {
return await ipcRenderer.invoke(channel);
} finally {
clearTimeout(timeoutHandle);
}
})());
// Race the `invoke` to the `setTimeout`
const result = await Promise.race([
firstInvoke,
timeout
]);
// If we have a result, return immediately
if (result) {
return result;
}
console.warn(`[preload] ipcRenderer.invoke(${channel}) did not return after ${retryDelay}ms. Retrying once...`);
// Otherwise, we retry once on the same channel
return ipcRenderer.invoke(channel);
}
//#endregion
//#region Resolve Configuration
/**
* @typedef {import('../common/sandboxTypes').ISandboxConfiguration} ISandboxConfiguration
*/
/** @type {ISandboxConfiguration | undefined} */
let configuration = undefined;
@@ -112,14 +71,7 @@
if (validateIPC(windowConfigIpcChannel)) {
// Resolve configuration from electron-main
//
// TODO@electron there seems to be a condition where an early
// `ipcRenderer.invoke` call does not return when running in
// smoke tests where a debugger is attached. The workaround
// here is to retry the call, but the underlying reasons are
// not yet understood.
// (https://github.com/microsoft/vscode/issues/146785)
configuration = await invokeWithRetry(windowConfigIpcChannel, 5000);
configuration = await ipcRenderer.invoke(windowConfigIpcChannel);
// Apply `userEnv` directly
Object.assign(process.env, configuration.userEnv);

View File

@@ -6,7 +6,6 @@
import { Workbench } from './workbench';
import { Code, launch, LaunchOptions } from './code';
import { Logger, measureAndLog } from './logger';
import { PlaywrightDriver } from './playwrightDriver';
export const enum Quality {
Dev,
@@ -135,10 +134,9 @@ export class Application {
}
private async checkWorkbenchReady(code: Code): Promise<void> {
const driver = code.driver;
// Web / Legacy: just poll for workbench element
if (this.web || !(driver instanceof PlaywrightDriver)) {
if (this.web) {
await measureAndLog(code.waitForElement('.monaco-workbench'), 'Application#checkWindowReady: wait for .monaco-workbench element', this.logger);
}
@@ -151,7 +149,7 @@ export class Application {
} catch (error) {
this.logger.log(`checkWindowReady: giving up after 10s, reloading window and trying again...`);
await driver.reload();
await code.driver.reload();
return this.checkWorkbenchReady(code);
}

View File

@@ -13,6 +13,8 @@ export function setup(logger: Logger) {
installAllHandlers(logger);
it('install and enable vscode-smoketest-check extension', async function () {
this.retries(3); // https://github.com/microsoft/vscode/issues/146800
const app = this.app as Application;
await app.workbench.extensions.openExtensionsViewlet();

View File

@@ -14,6 +14,8 @@ export function setup(logger: Logger) {
installAllHandlers(logger);
it('starts with "DE" locale and verifies title and viewlets text is in German', async function () {
this.retries(3); // https://github.com/microsoft/vscode/issues/146800
const app = this.app as Application;
await app.workbench.extensions.openExtensionsViewlet();
await app.workbench.extensions.installExtension('ms-ceintl.vscode-language-pack-de', false);