From 55759234d736b6e7d2c50bebab0e7283fd01f691 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 14 Apr 2022 08:14:40 +0200 Subject: [PATCH] preload - revert retry logic which does not seem to help --- .../parts/sandbox/electron-browser/preload.js | 58 ++----------------- test/automation/src/application.ts | 6 +- .../src/areas/extensions/extensions.test.ts | 2 + .../src/areas/workbench/localization.test.ts | 2 + 4 files changed, 11 insertions(+), 57 deletions(-) diff --git a/src/vs/base/parts/sandbox/electron-browser/preload.js b/src/vs/base/parts/sandbox/electron-browser/preload.js index 3b74b9236e1..d8cc4c63220 100644 --- a/src/vs/base/parts/sandbox/electron-browser/preload.js +++ b/src/vs/base/parts/sandbox/electron-browser/preload.js @@ -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} - */ - 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); diff --git a/test/automation/src/application.ts b/test/automation/src/application.ts index 8914ed55982..4506ed8e14e 100644 --- a/test/automation/src/application.ts +++ b/test/automation/src/application.ts @@ -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 { - 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); } diff --git a/test/smoke/src/areas/extensions/extensions.test.ts b/test/smoke/src/areas/extensions/extensions.test.ts index 7a4875bcd7f..9bf6dd79b07 100644 --- a/test/smoke/src/areas/extensions/extensions.test.ts +++ b/test/smoke/src/areas/extensions/extensions.test.ts @@ -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(); diff --git a/test/smoke/src/areas/workbench/localization.test.ts b/test/smoke/src/areas/workbench/localization.test.ts index afa4e9fced4..61b354a22f3 100644 --- a/test/smoke/src/areas/workbench/localization.test.ts +++ b/test/smoke/src/areas/workbench/localization.test.ts @@ -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);