Skip to content

Commit 261235c

Browse files
committed
feat(replay): Do not log "timeout while trying to read resp body" as exception (#13965)
Change this to be a warn level log instead of an exception (which gets captured to Sentry). Since this is an error we are throwing ourselves and it is to be expected, no need to treat as an exception. This also adds a new meta string to differentiate from an error while parsing. This means we can show a more specific error message on the frontend.
1 parent 78e8a39 commit 261235c

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

packages/replay-internal/src/coreHandlers/util/fetchUtils.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ async function _parseFetchResponseBody(response: Response): Promise<[string | un
209209
const text = await _tryGetResponseText(res);
210210
return [text];
211211
} catch (error) {
212+
if (error instanceof Error && error.message.indexOf('Timeout') > -1) {
213+
DEBUG_BUILD && logger.warn('Parsing text body from response timed out');
214+
return [undefined, 'BODY_PARSE_TIMEOUT'];
215+
}
216+
212217
DEBUG_BUILD && logger.exception(error, 'Failed to get text body from response');
213218
return [undefined, 'BODY_PARSE_ERROR'];
214219
}
@@ -299,8 +304,6 @@ function _tryGetResponseText(response: Response): Promise<string | undefined> {
299304
)
300305
.finally(() => clearTimeout(timeout));
301306
});
302-
303-
return _getResponseText(response);
304307
}
305308

306309
async function _getResponseText(response: Response): Promise<string> {

packages/replay-internal/src/types/request.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type NetworkMetaWarning =
88
| 'TEXT_TRUNCATED'
99
| 'URL_SKIPPED'
1010
| 'BODY_PARSE_ERROR'
11+
| 'BODY_PARSE_TIMEOUT'
1112
| 'UNPARSEABLE_BODY_TYPE';
1213

1314
interface NetworkMeta {

packages/replay-internal/test/unit/coreHandlers/util/fetchUtils.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ describe('Unit | coreHandlers | util | fetchUtils', () => {
132132
]);
133133

134134
expect(res).toEqual({
135-
_meta: { warnings: ['BODY_PARSE_ERROR'] },
135+
_meta: { warnings: ['BODY_PARSE_TIMEOUT'] },
136136
headers: {},
137137
size: undefined,
138138
});

0 commit comments

Comments
 (0)