From 4674f21a708c8221b9cdb87d80c964eb451c6fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 14 May 2024 15:13:43 +0200 Subject: [PATCH] Await `onApiCallEnd`/`onApiCallBegin` hooks --- packages/playwright-core/src/client/channelOwner.ts | 7 ++++--- .../playwright-core/src/client/clientInstrumentation.ts | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.ts index 8670ebbea2..04af8c5aea 100644 --- a/packages/playwright-core/src/client/channelOwner.ts +++ b/packages/playwright-core/src/client/channelOwner.ts @@ -146,7 +146,8 @@ export abstract class ChannelOwner ${apiName} started`, isInternal); const apiZone: ApiZone = { apiName, frames, isInternal, reported: false, csi, callCookie, wallTime }; const result = await zones.run('apiZone', apiZone, async () => await func(apiZone)); - csi?.onApiCallEnd(callCookie); + await csi?.onApiCallEnd(callCookie); logApiCall(logger, `<= ${apiName} succeeded`, isInternal); return result; } catch (e) { @@ -200,7 +201,7 @@ export abstract class ChannelOwner, frames: StackFrame[], wallTime: number, userData: any): void; - onApiCallEnd(userData: any, error?: Error): void; + onApiCallBegin(apiCall: string, params: Record, frames: StackFrame[], wallTime: number, userData: any): Promise | void; + onApiCallEnd(userData: any, error?: Error): Promise | void; onDidCreateBrowserContext(context: BrowserContext): Promise; onDidCreateRequestContext(context: APIRequestContext): Promise; onWillPause(): void; @@ -32,8 +32,8 @@ export interface ClientInstrumentation { } export interface ClientInstrumentationListener { - onApiCallBegin?(apiName: string, params: Record, frames: StackFrame[], wallTime: number, userData: any): void; - onApiCallEnd?(userData: any, error?: Error): void; + onApiCallBegin?(apiName: string, params: Record, frames: StackFrame[], wallTime: number, userData: any): Promise | void; + onApiCallEnd?(userData: any, error?: Error): Promise | void; onDidCreateBrowserContext?(context: BrowserContext): Promise; onDidCreateRequestContext?(context: APIRequestContext): Promise; onWillPause?(): void;