Skip to content

Commit

Permalink
hjtest
Browse files Browse the repository at this point in the history
  • Loading branch information
Helen Jiang authored and Helen Jiang committed Oct 24, 2024
1 parent 576b564 commit 16d656c
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions lib/resources/timingSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,27 @@ export function serializeEntryToArray(entry: PerformanceResourceTiming) {
}

let backendTraceId = '';
if (!isCached){
try {
const serverTimings = entry['serverTiming'];
if (serverTimings instanceof Array) {
for (let i = 0; i < serverTimings.length; i++) {
const serverTiming = serverTimings[i];
if (serverTiming['name'] === vars.serverTimingBackendTraceIdEntryName) {
backendTraceId = serverTiming['description'];
try {
const serverTimings = entry['serverTiming'];
if (serverTimings instanceof Array) {
for (const element of serverTimings) {
const serverTiming = element;
if (serverTiming['name'] === vars.serverTimingBackendTraceIdEntryName) {
backendTraceId = serverTiming['description'];
if (isCached) {
if (DEBUG) {
info('Response is cached, removed backendTraceId from response');
}
backendTraceId = '';
}
}
}
} catch (e) {
// Some browsers may not grant access to the field when the Timing-Allow-Origin
// check fails. Better be safe than sorry here.
}
} catch (e) {
// Some browsers may not grant access to the field when the Timing-Allow-Origin
// check fails. Better be safe than sorry here.
}
else {
info('Response is cached, removed backendTraceId from response');
}

result.push(backendTraceId);

if (hasValidTimings) {
Expand Down

0 comments on commit 16d656c

Please sign in to comment.