Skip to content

Commit

Permalink
[Fix] Adds try/catch to gracefully handle performance observer except…
Browse files Browse the repository at this point in the history
…ion (#35202)

* fix: add try/catch to gracefull handle performance observer exception on older browsers

* fix: run prettier

Co-authored-by: Steven <steven@ceriously.com>
  • Loading branch information
huzaifarif and styfle committed Mar 10, 2022
1 parent 0355e5f commit ea87415
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/next/client/image.tsx
Expand Up @@ -516,7 +516,15 @@ export default function Image({
}
}
})
perfObserver.observe({ type: 'largest-contentful-paint', buffered: true })
try {
perfObserver.observe({
type: 'largest-contentful-paint',
buffered: true,
})
} catch (err) {
// Log error but don't crash the app
console.error(err)
}
}
}

Expand Down

0 comments on commit ea87415

Please sign in to comment.