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> {
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<string> {

View file

@ -258,7 +258,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({
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<TestStepInternal>('stepZone');
if (zone && zone.category === 'expect') {