Skip to content

Commit

Permalink
Protection when serverTiming doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Sep 29, 2017
1 parent 8ac0c8b commit c662a32
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions perfbar.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ var UW = unsafeWindow;
function updateReq() {
let edgeTime = 0
for (const {name: url, serverTiming} of performance.getEntriesByType('navigation')) {
for (const {name, metric, duration, value} of serverTiming) {
for (const {name, metric, duration, value} of (serverTiming || [])) {
if (['cret', 'ctt'].indexOf(name || metric) !== -1) {
edgeTime += (typeof duration !== 'undefined' ? duration : value)
}
Expand Down Expand Up @@ -816,7 +816,7 @@ var UW = unsafeWindow;
}
function cachedAtEdge({name, serverTiming}) {
var origin
serverTiming.forEach(function(st) {
(serverTiming || []).forEach(function(st) {
if (st.name === 'origin' || st.metric === 'origin') {
console.info(name, st.description)
origin = st.description === false
Expand Down

0 comments on commit c662a32

Please sign in to comment.