Skip to content

Commit

Permalink
fix: captured network requests must always have name property
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Sep 3, 2024
1 parent a0a5f1d commit ce355d4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/entrypoints/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ function initXhrObserver(cb: networkCallback, win: IWindow, options: Required<Ne
networkRequest,
start,
end,
url: url.toString(),
})
cb({ requests })
})
Expand Down Expand Up @@ -353,6 +354,7 @@ function prepareRequest({
isInitial,
start,
end,
url,
}: {
entry: PerformanceResourceTiming | null
method: string | undefined
Expand All @@ -361,6 +363,8 @@ function prepareRequest({
isInitial?: boolean
start?: number
end?: number
// if there is no entry, we still need to know the url
url?: string
}): CapturedNetworkRequest[] {
start = entry ? entry.startTime : start
end = entry ? entry.responseEnd : end
Expand All @@ -375,7 +379,7 @@ function prepareRequest({
// use timeOrigin if we really can't gather a start time
const timestamp = Math.floor(timeOrigin + (start || 0))

const entryJSON = entry ? entry.toJSON() : {}
const entryJSON = entry ? entry.toJSON() : { name: url }

const requests: CapturedNetworkRequest[] = [
{
Expand Down Expand Up @@ -578,6 +582,7 @@ function initFetchObserver(
networkRequest,
start,
end,
url: req.url,
})
cb({ requests })
})
Expand Down

0 comments on commit ce355d4

Please sign in to comment.