Skip to content

Commit 30c497b

Browse files
committed
fix peek race condition
1 parent 9258234 commit 30c497b

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

test/smoke/src/areas/editor/peek.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,19 @@ export class References {
3434
}
3535

3636
async close(): Promise<void> {
37-
await this.code.dispatchKeybinding('escape');
38-
await this.code.waitForElement(References.REFERENCES_WIDGET, element => !element);
37+
// Sometimes someone else eats up the `Escape` key
38+
let count = 0;
39+
while (true) {
40+
await this.code.dispatchKeybinding('escape');
41+
42+
try {
43+
await this.code.waitForElement(References.REFERENCES_WIDGET, el => !el, 10);
44+
return;
45+
} catch (err) {
46+
if (++count > 5) {
47+
throw err;
48+
}
49+
}
50+
}
3951
}
4052
}

test/smoke/src/vscode/code.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ export class Code {
242242
return await poll(() => this.driver.getElements(windowId, selector, recursive), accept, `get elements '${selector}'`);
243243
}
244244

245-
async waitForElement(selector: string, accept: (result: IElement | undefined) => boolean = result => !!result): Promise<IElement> {
245+
async waitForElement(selector: string, accept: (result: IElement | undefined) => boolean = result => !!result, retryCount: number = 200): Promise<IElement> {
246246
const windowId = await this.getActiveWindowId();
247-
return await poll<IElement>(() => this.driver.getElements(windowId, selector).then(els => els[0]), accept, `get element '${selector}'`);
247+
return await poll<IElement>(() => this.driver.getElements(windowId, selector).then(els => els[0]), accept, `get element '${selector}'`, retryCount);
248248
}
249249

250250
async waitForActiveElement(selector: string, retryCount: number = 200): Promise<void> {

0 commit comments

Comments
 (0)