Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PerformanceObserver.observe() breaks inside next/image on chrome 69 #35200

Closed
1 task done
huzaifarif opened this issue Mar 10, 2022 · 2 comments · Fixed by #35202
Closed
1 task done

PerformanceObserver.observe() breaks inside next/image on chrome 69 #35200

huzaifarif opened this issue Mar 10, 2022 · 2 comments · Fixed by #35202
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.

Comments

@huzaifarif
Copy link
Contributor

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101
Binaries:
  Node: 15.14.0
  npm: 7.7.6
  Yarn: 3.0.1
  pnpm: N/A
Relevant packages:
  next: 12.0.10
  react: 0.0.4
  react-dom: 0.0.4

What browser are you using? (if relevant)

Chrome 69.0.3497.106

How are you deploying your application? (if relevant)

No response

Describe the Bug

TL,DR
performanceObserver.observe() throws an exception when not provided with the entryTypes option in older browsers like Chrome 69.

Description:
When using next/image, it internally attaches performance observer for LargestContentfulPaint events.
On older browsers like Chromium 69 this fails with the following error:
TypeError: Failed to execute 'observe' on 'PerformanceObserver': required member entryTypes is undefined.

While the current implementation follows the latest w3c specs which specifies that performanceObserver.observe() must be passed either entryTypes array or type and buffered as options, next/image usses the later here: https://github.com/vercel/next.js/blob/canary/packages/next/client/image.tsx#L519

But Chrome 69 enforces that entryTypes must be provided to observe(), hence it throws an exception.

image

Expected Behavior

performanceObserver.observe() should be wrapped inside a try/catch block

To Reproduce

Use next/image in an older browser like Chrome 69

@huzaifarif huzaifarif added the bug Issue was opened via the bug report template. label Mar 10, 2022
@neeraj3029
Copy link
Contributor

neeraj3029 commented Mar 10, 2022

I agree with this change. I was also able to reproduce this issue with Performance Observer failing on browserstack Chrome 65.

My opinion is, the error can be contained and should not break the Image component from getting rendered.

Screenshot 2022-03-10 at 3 44 14 PM

@balazsorban44 balazsorban44 added the Image (next/image) Related to Next.js Image Optimization. label Mar 10, 2022
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants