test: fixed flaky connectOverCDP tests (#6436)
This commit is contained in:
parent
217cbe3e21
commit
d902b06fd1
|
|
@ -186,7 +186,8 @@ export abstract class BrowserType extends SdkObject {
|
||||||
await validateHostRequirements(this._registry, options.channel as registry.BrowserName);
|
await validateHostRequirements(this._registry, options.channel as registry.BrowserName);
|
||||||
|
|
||||||
let wsEndpointCallback: ((wsEndpoint: string) => void) | undefined;
|
let wsEndpointCallback: ((wsEndpoint: string) => void) | undefined;
|
||||||
const wsEndpoint = options.useWebSocket ? new Promise<string>(f => wsEndpointCallback = f) : undefined;
|
const shouldWaitForWSListening = options.useWebSocket || options.args?.some(a => a.startsWith('--remote-debugging-port'));
|
||||||
|
const waitForWSEndpoint = shouldWaitForWSListening ? new Promise<string>(f => wsEndpointCallback = f) : undefined;
|
||||||
// Note: it is important to define these variables before launchProcess, so that we don't get
|
// Note: it is important to define these variables before launchProcess, so that we don't get
|
||||||
// "Cannot access 'browserServer' before initialization" if something went wrong.
|
// "Cannot access 'browserServer' before initialization" if something went wrong.
|
||||||
let transport: ConnectionTransport | undefined = undefined;
|
let transport: ConnectionTransport | undefined = undefined;
|
||||||
|
|
@ -242,8 +243,11 @@ export abstract class BrowserType extends SdkObject {
|
||||||
kill
|
kill
|
||||||
};
|
};
|
||||||
progress.cleanupWhenAborted(() => closeOrKill(progress.timeUntilDeadline()));
|
progress.cleanupWhenAborted(() => closeOrKill(progress.timeUntilDeadline()));
|
||||||
|
let wsEndpoint: string | undefined;
|
||||||
|
if (shouldWaitForWSListening)
|
||||||
|
wsEndpoint = await waitForWSEndpoint;
|
||||||
if (options.useWebSocket) {
|
if (options.useWebSocket) {
|
||||||
transport = await WebSocketTransport.connect(progress, await wsEndpoint!);
|
transport = await WebSocketTransport.connect(progress, wsEndpoint!);
|
||||||
} else {
|
} else {
|
||||||
const stdio = launchedProcess.stdio as unknown as [NodeJS.ReadableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.ReadableStream];
|
const stdio = launchedProcess.stdio as unknown as [NodeJS.ReadableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.WritableStream, NodeJS.ReadableStream];
|
||||||
transport = new PipeTransport(stdio[3], stdio[4]);
|
transport = new PipeTransport(stdio[3], stdio[4]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue