Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ async function _parseFetchResponseBody(response: Response): Promise<[string | un
const text = await _tryGetResponseText(res);
return [text];
} catch (error) {
if (error instanceof Error && error.message.indexOf('Timeout') > -1) {
DEBUG_BUILD && logger.warn('Parsing text body from response timed out');
return [undefined, 'BODY_PARSE_TIMEOUT'];
}

DEBUG_BUILD && logger.exception(error, 'Failed to get text body from response');
return [undefined, 'BODY_PARSE_ERROR'];
}
Expand Down Expand Up @@ -299,8 +304,6 @@ function _tryGetResponseText(response: Response): Promise<string | undefined> {
)
.finally(() => clearTimeout(timeout));
});

return _getResponseText(response);
Comment on lines -302 to -303
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unreachable code

}

async function _getResponseText(response: Response): Promise<string> {
Expand Down
1 change: 1 addition & 0 deletions packages/replay-internal/src/types/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type NetworkMetaWarning =
| 'TEXT_TRUNCATED'
| 'URL_SKIPPED'
| 'BODY_PARSE_ERROR'
| 'BODY_PARSE_TIMEOUT'
| 'UNPARSEABLE_BODY_TYPE';

interface NetworkMeta {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe('Unit | coreHandlers | util | fetchUtils', () => {
]);

expect(res).toEqual({
_meta: { warnings: ['BODY_PARSE_ERROR'] },
_meta: { warnings: ['BODY_PARSE_TIMEOUT'] },
headers: {},
size: undefined,
});
Expand Down
Loading