Skip to content

fix: Prevent TypeError from deprecated addListener API#3992

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/gazebo-17z7-polyfill-addlistener
Open

fix: Prevent TypeError from deprecated addListener API#3992
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/gazebo-17z7-polyfill-addlistener

Conversation

@sentry

@sentry sentry Bot commented Jun 4, 2026

Copy link
Copy Markdown

Description

This PR addresses GAZEBO-17Z7, a TypeError: Cannot read properties of undefined (reading 'addListener') occurring on commit detail pages.

Root Cause:
The react-hot-toast library (v2.4.1) internally uses the deprecated MediaQueryList.prototype.addListener method to detect dark mode preferences. In certain browser environments (e.g., Edge 150), this deprecated method is undefined, leading to a TypeError when react-hot-toast attempts to call it without a null-check.

Solution:

  1. Added src/polyfills/mediaQueryList.ts: This new file provides a polyfill for MediaQueryList.prototype.addListener and MediaQueryList.prototype.removeListener. If these deprecated methods are found to be undefined, the polyfill shims them to delegate to their modern counterparts, addEventListener('change', ...) and removeEventListener('change', ...), respectively.
  2. Imported polyfill in src/index.tsx: The polyfill is imported as the very first statement in src/index.tsx. This ensures that the polyfill is active and the addListener method is available before react-hot-toast (or any other library) initializes and attempts to use it.

Code Example

Notable Changes

  1. Added src/polyfills/mediaQueryList.ts to provide a polyfill for MediaQueryList.prototype.addListener and MediaQueryList.prototype.removeListener.
  2. Imported the new polyfill in src/index.tsx as the very first statement to ensure it's active globally before other libraries initialize.

Screenshots

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes GAZEBO-17Z7

@sentry

sentry Bot commented Jun 4, 2026

Copy link
Copy Markdown
Author

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.67%. Comparing base (b33c3d9) to head (67469e7).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/polyfills/mediaQueryList.ts 0.00% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3992      +/-   ##
==========================================
- Coverage   98.73%   98.67%   -0.06%     
==========================================
  Files         827      828       +1     
  Lines       15133    15142       +9     
  Branches     4357     4367      +10     
==========================================
  Hits        14942    14942              
- Misses        184      191       +7     
- Partials        7        9       +2     
Files with missing lines Coverage Δ
src/polyfills/mediaQueryList.ts 0.00% <0.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <ø> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <ø> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b33c3d9...67469e7. Read the comment docs.

@codecov-notifications

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/polyfills/mediaQueryList.ts 0.00% 7 Missing and 2 partials ⚠️
@@            Coverage Diff             @@
##             main    #3992      +/-   ##
==========================================
- Coverage   98.73%   98.67%   -0.06%     
==========================================
  Files         827      828       +1     
  Lines       15133    15142       +9     
  Branches     4357     4367      +10     
==========================================
  Hits        14942    14942              
- Misses        184      191       +7     
- Partials        7        9       +2     
Files with missing lines Coverage Δ
src/polyfills/mediaQueryList.ts 0.00% <0.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <ø> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <ø> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b33c3d9...67469e7. Read the comment docs.

@codecov-public-qa

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Project coverage is 98.67%. Comparing base (b33c3d9) to head (67469e7).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/polyfills/mediaQueryList.ts 0.00% 7 Missing and 2 partials ⚠️
@@            Coverage Diff             @@
##             main    #3992      +/-   ##
==========================================
- Coverage   98.73%   98.67%   -0.06%     
==========================================
  Files         827      828       +1     
  Lines       15133    15142       +9     
  Branches     4357     4367      +10     
==========================================
  Hits        14942    14942              
- Misses        184      191       +7     
- Partials        7        9       +2     
Files with missing lines Coverage Δ
src/polyfills/mediaQueryList.ts 0.00% <0.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <ø> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <ø> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b33c3d9...67469e7. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codecov-qa

codecov-qa Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.67%. Comparing base (b33c3d9) to head (67469e7).

Files with missing lines Patch % Lines
src/polyfills/mediaQueryList.ts 0.00% 7 Missing and 2 partials ⚠️
@@            Coverage Diff             @@
##             main    #3992      +/-   ##
==========================================
- Coverage   98.73%   98.67%   -0.06%     
==========================================
  Files         827      828       +1     
  Lines       15133    15142       +9     
  Branches     4357     4367      +10     
==========================================
  Hits        14942    14942              
- Misses        184      191       +7     
- Partials        7        9       +2     
Files with missing lines Coverage Δ
src/polyfills/mediaQueryList.ts 0.00% <0.00%> (ø)
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 99.71% <ø> (ø)
Pages 98.37% <ø> (ø)
Services 99.32% <ø> (ø)
Shared 98.95% <ø> (ø)
UI 99.01% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b33c3d9...67469e7. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants