Skip to content
Open
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 @@ -95,6 +95,6 @@ function _isXhrHint(hint?: BreadcrumbHint): hint is XhrHint {
return hint?.xhr;
}

function _isFetchHint(hint?: BreadcrumbHint): hint is FetchHint {
return hint?.response;
function _isFetchHint(hint?: BreadcrumbHint): hint is Partial<FetchHint> {
return hint?.input !== undefined;
}
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,56 @@ other-header: test`;
]);
});

it('handles fetch breadcrumb for aborted request (no response)', async () => {
const breadcrumb: Breadcrumb = {
category: 'fetch',
level: 'error',
data: {
method: 'GET',
url: 'https://example.com',
},
};

const hint: FetchBreadcrumbHint = {
data: new Error('The operation was aborted'),
input: ['GET', {}],
startTimestamp: BASE_TIMESTAMP + 1000,
endTimestamp: BASE_TIMESTAMP + 2000,
};
beforeAddNetworkBreadcrumb(options, breadcrumb, hint);

expect(breadcrumb).toEqual({
category: 'fetch',
level: 'error',
data: {
method: 'GET',
url: 'https://example.com',
},
});

await waitForReplayEventBuffer();

expect((options.replay.eventBuffer as EventBufferArray).events).toEqual([
{
type: 5,
timestamp: (BASE_TIMESTAMP + 1000) / 1000,
data: {
tag: 'performanceSpan',
payload: {
data: {
method: 'GET',
statusCode: 0,
},
description: 'https://example.com',
endTimestamp: (BASE_TIMESTAMP + 2000) / 1000,
op: 'resource.fetch',
startTimestamp: (BASE_TIMESTAMP + 1000) / 1000,
},
},
},
]);
});

it('parses fetch response body if necessary', async () => {
const breadcrumb: Breadcrumb = {
category: 'fetch',
Expand Down
Loading