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
Exception: Cannot set property matchMedia of [object Object] which has only a getter #18774
Comments
@Chidi3b3r3 Please add any comments you have on this issue as I believe you have seen it as well. |
Hello @drush. Please provide a online reproduction by forking this link https://u.ant.design/codesandbox-repro or a minimal GitHub repository. Issues labeled by 你好 @drush, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。7 天内未跟进的 issue 将会被自动关闭。 |
If it only happen in production environment? In some case |
We are seeing this error in the Sider: We have not been able to reproduce in production or development, but are seeing a steady stream of these exceptions in our production crash reports. The |
Our stack uses webpack and babel (7.3.4 ATM). This issue references the 'babel re-export only getters' issue Tried this to attempt a repro in the console, but could not get it to fail.
|
FWIW this refactor would fix the issue regardless:
|
The properties of But the The reason we have to re-assign But We can force assignment by
|
Reproduction link
https://gist.github.com/drush/22bbd7134f4a54d96b811b170de72d9e
Steps to reproduce
Have not been able to reproduce, although can see this exception thrown in FE crash reports across several different browsers over several weeks of app operation in production.
What is expected?
An exception should not be thrown.
Simple tests in console make it appear that window.matchMedia is settable, but have not been able to identify if there are lockdown browser features or an extension that might be overriding this.
What is actually happening?
window.matchMedia = window.matchMedia || matchMediaPolyfill;
throws an exception. We see this in production across Chrome and Edge - all on Windows so far. Affecting at least 10 different versions of Chrome (60-76) and 2 versions of Edge.
Cannot set property matchMedia of [object Object] which has only a getter
This same code appears in:
Sider, Carousel and responsiveObserve
https://github.com/ant-design/ant-design/search?q=%22window.matchMedia %3D%22&unscoped_q=%22window.matchMedia %3D%22
It seems that in some cases, the window.matchMedia attribute cannot be set. This may be some additional enterprise security setting, or other locked-down feature in the browser that some users have turned on.
SUGGESTED REMEDY:
window.xxMatchMedia
This earlier case reports the same issue but did not provide repro details: #15289
The text was updated successfully, but these errors were encountered: