mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: propagate client-side instrumentation across connect (#23524)
Fixes https://github.com/microsoft/playwright/issues/23504
This commit is contained in:
parent
2200892ac3
commit
def24c0a14
@ -71,7 +71,7 @@ export class Android extends ChannelOwner<channels.AndroidChannel> implements ap
|
||||
const connectParams: channels.LocalUtilsConnectParams = { wsEndpoint, headers, slowMo: options.slowMo, timeout: options.timeout };
|
||||
const { pipe } = await localUtils._channel.connect(connectParams);
|
||||
const closePipe = () => pipe.close().catch(() => {});
|
||||
const connection = new Connection(localUtils);
|
||||
const connection = new Connection(localUtils, this._instrumentation);
|
||||
connection.markAsRemote();
|
||||
connection.on('close', closePipe);
|
||||
|
||||
|
@ -156,7 +156,7 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel> imple
|
||||
connectParams.socksProxyRedirectPortForTest = (params as any).__testHookRedirectPortForwarding;
|
||||
const { pipe, headers: connectHeaders } = await localUtils._channel.connect(connectParams);
|
||||
const closePipe = () => pipe.close().catch(() => {});
|
||||
const connection = new Connection(localUtils);
|
||||
const connection = new Connection(localUtils, this._instrumentation);
|
||||
connection.markAsRemote();
|
||||
connection.on('close', closePipe);
|
||||
|
||||
|
@ -45,6 +45,7 @@ import { LocalUtils } from './localUtils';
|
||||
import { Tracing } from './tracing';
|
||||
import { findValidator, ValidationError, type ValidatorContext } from '../protocol/validator';
|
||||
import { createInstrumentation } from './clientInstrumentation';
|
||||
import type { ClientInstrumentation } from './clientInstrumentation';
|
||||
|
||||
class Root extends ChannelOwner<channels.RootChannel> {
|
||||
constructor(connection: Connection) {
|
||||
@ -73,12 +74,13 @@ export class Connection extends EventEmitter {
|
||||
// Some connections allow resolving in-process dispatchers.
|
||||
toImpl: ((client: ChannelOwner) => any) | undefined;
|
||||
private _tracingCount = 0;
|
||||
readonly _instrumentation = createInstrumentation();
|
||||
readonly _instrumentation: ClientInstrumentation;
|
||||
|
||||
constructor(localUtils?: LocalUtils) {
|
||||
constructor(localUtils: LocalUtils | undefined, instrumentation: ClientInstrumentation | undefined) {
|
||||
super();
|
||||
this._rootObject = new Root(this);
|
||||
this._localUtils = localUtils;
|
||||
this._instrumentation = instrumentation || createInstrumentation();
|
||||
}
|
||||
|
||||
markAsRemote() {
|
||||
|
@ -24,7 +24,7 @@ import type { Language } from './utils/isomorphic/locatorGenerators';
|
||||
export function createInProcessPlaywright(): PlaywrightAPI {
|
||||
const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });
|
||||
|
||||
const clientConnection = new Connection();
|
||||
const clientConnection = new Connection(undefined, undefined);
|
||||
const dispatcherConnection = new DispatcherConnection(true /* local */);
|
||||
|
||||
// Dispatch synchronously at first.
|
||||
|
@ -45,7 +45,7 @@ class PlaywrightClient {
|
||||
this._driverProcess.unref();
|
||||
this._driverProcess.stderr!.on('data', data => process.stderr.write(data));
|
||||
|
||||
const connection = new Connection();
|
||||
const connection = new Connection(undefined, undefined);
|
||||
connection.markAsRemote();
|
||||
const transport = new PipeTransport(this._driverProcess.stdin!, this._driverProcess.stdout!);
|
||||
connection.onmessage = message => transport.send(JSON.stringify(message));
|
||||
|
Loading…
x
Reference in New Issue
Block a user