From b864458988df43d90bd8640fd51fe0ae72ed7736 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Tue, 25 Feb 2025 13:33:03 +0100 Subject: [PATCH] use wrapApiCall --- packages/playwright-core/src/client/fetch.ts | 22 +++++++++++--------- packages/playwright/src/index.ts | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/playwright-core/src/client/fetch.ts b/packages/playwright-core/src/client/fetch.ts index 8bdf38631d..dada11ed30 100644 --- a/packages/playwright-core/src/client/fetch.ts +++ b/packages/playwright-core/src/client/fetch.ts @@ -338,16 +338,18 @@ export class APIResponse implements api.APIResponse { } async body(): Promise { - try { - const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }); - if (result.binary === undefined) - throw new Error('Response has been disposed'); - return result.binary; - } catch (e) { - if (isTargetClosedError(e)) - throw new Error('Response has been disposed'); - throw e; - } + return await this._request._wrapApiCall(async () => { + try { + const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }); + if (result.binary === undefined) + throw new Error('Response has been disposed'); + return result.binary; + } catch (e) { + if (isTargetClosedError(e)) + throw new Error('Response has been disposed'); + throw e; + } + }, true); } async text(): Promise { diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.ts index 8e17c5f870..e8afe5a74a 100644 --- a/packages/playwright/src/index.ts +++ b/packages/playwright/src/index.ts @@ -258,7 +258,7 @@ const playwrightFixtures: Fixtures = ({ onApiCallBegin: (data: ApiCallData) => { const testInfo = currentTestInfo(); // Some special calls do not get into steps. - if (!testInfo || data.apiName.includes('setTestIdAttribute') || data.apiName === 'tracing.groupEnd' || data.apiName.startsWith('apiResponse.')) + if (!testInfo || data.apiName.includes('setTestIdAttribute') || data.apiName === 'tracing.groupEnd') return; const zone = currentZone().data('stepZone'); if (zone && zone.category === 'expect') {