Skip to content

Commit 7d47d6b

Browse files
authored
fix: indicate when request and response bodies are not available (#446)
1 parent b443033 commit 7d47d6b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/formatters/networkFormatter.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ export async function getFormattedResponseBody(
6868

6969
return `<binary data>`;
7070
} catch {
71-
// buffer() call might fail with CDP exception, in this case we don't print anything in the context
72-
return;
71+
return `<not available anymore>`;
7372
}
7473
}
7574

@@ -91,8 +90,7 @@ export async function getFormattedRequestBody(
9190
return `${getSizeLimitedString(fetchData, sizeLimit)}`;
9291
}
9392
} catch {
94-
// fetchPostData() call might fail with CDP exception, in this case we don't print anything in the context
95-
return;
93+
return `<not available anymore>`;
9694
}
9795
}
9896

tests/formatters/networkFormatter.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe('networkFormatter', () => {
115115

116116
assert.strictEqual(result, 'test');
117117
});
118-
it('shows empty string when no postData available', async () => {
118+
it('shows not available when no postData available', async () => {
119119
const request = getMockRequest({
120120
hasPostData: false,
121121
});
@@ -164,7 +164,7 @@ describe('networkFormatter', () => {
164164

165165
assert.strictEqual(result, 'some text that is lo... <truncated>');
166166
});
167-
it('shows nothing on exception', async () => {
167+
it('shows not available on exception', async () => {
168168
const request = getMockRequest({
169169
hasPostData: true,
170170
postData: undefined,
@@ -173,7 +173,7 @@ describe('networkFormatter', () => {
173173

174174
const result = await getFormattedRequestBody(request, 200);
175175

176-
assert.strictEqual(result, undefined);
176+
assert.strictEqual(result, '<not available anymore>');
177177
});
178178
});
179179

@@ -232,7 +232,7 @@ describe('networkFormatter', () => {
232232

233233
const result = await getFormattedResponseBody(response, 200);
234234

235-
assert.strictEqual(result, undefined);
235+
assert.strictEqual(result, '<not available anymore>');
236236
});
237237
});
238238
});

0 commit comments

Comments
 (0)