Skip to content

Commit

Permalink
prevent unbounded growth
Browse files Browse the repository at this point in the history
  • Loading branch information
samouri committed Mar 16, 2021
1 parent cb0bde6 commit 1c5f13a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/service/performance-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,8 @@ export class Performance {
} else if (entry.entryType === 'layout-shift') {
// Ignore layout shift that occurs within 500ms of user input, as it is
// likely in response to the user's action.
if (!entry.hadRecentInput) {
// 1000 here is a magic number to prevent unbounded growth. We don't expect it to be reached.
if (!entry.hadRecentInput && this.layoutShifts_.length < 1000) {
this.layoutShifts_.push(entry);
}
} else if (entry.entryType === 'largest-contentful-paint') {
Expand Down

0 comments on commit 1c5f13a

Please sign in to comment.