use wrapApiCall

This commit is contained in:
Simon Knott 2025-02-25 13:33:03 +01:00
parent 8ab12c0779
commit b864458988
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 13 additions and 11 deletions

View file

@ -338,16 +338,18 @@ export class APIResponse implements api.APIResponse {
} }
async body(): Promise<Buffer> { async body(): Promise<Buffer> {
try { return await this._request._wrapApiCall(async () => {
const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() }); try {
if (result.binary === undefined) const result = await this._request._channel.fetchResponseBody({ fetchUid: this._fetchUid() });
throw new Error('Response has been disposed'); if (result.binary === undefined)
return result.binary; throw new Error('Response has been disposed');
} catch (e) { return result.binary;
if (isTargetClosedError(e)) } catch (e) {
throw new Error('Response has been disposed'); if (isTargetClosedError(e))
throw e; throw new Error('Response has been disposed');
} throw e;
}
}, true);
} }
async text(): Promise<string> { async text(): Promise<string> {

View file

@ -258,7 +258,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
onApiCallBegin: (data: ApiCallData) => { onApiCallBegin: (data: ApiCallData) => {
const testInfo = currentTestInfo(); const testInfo = currentTestInfo();
// Some special calls do not get into steps. // 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; return;
const zone = currentZone().data<TestStepInternal>('stepZone'); const zone = currentZone().data<TestStepInternal>('stepZone');
if (zone && zone.category === 'expect') { if (zone && zone.category === 'expect') {