react-native-device-info: Illegal invocation from getBattery call
Not 100% sure if this is actually an issue within this project, but though I would ask if someone happens to have some information on this.
Summary
Affected platform: web
Version | 6.2.1 |
Affected OS | all |
OS Version | No pattern |
Current behavior
Some users apparently receive TypeError: Failed to execute 'getBattery' on 'Navigator': Illegal invocation.
This is coming from react-native-device-info/lib/module/web/index.js in init
.
I did some research and error would indicate that the call is missing context (for navigator object), but based on code I have no idea how this could be. Perhaps the call should be prefixed with window.
?
So far we have had 156 users getting this error, so it seems pretty common although it does not happen to me.
Expected behavior
If getBattery call is found from navigator, call should not give error and no call should happen if method is not supported.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 19 (2 by maintainers)
Commits related to this issue
- fix(web, init): use Promise so that the navigator context is known to its method resolves #1223 — committed to antoinewg/react-native-device-info by antoinewg 3 years ago
- fix(web): Illegal invocation from getBattery call (#1333) * fix(web, init): use Promise so that the navigator context is known to its method resolves #1223 * fix(web, isBatteryCharging): get ba... — committed to react-native-device-info/react-native-device-info by antoinewg 2 years ago
- chore(release): 9.0.1 [skip ci] ## [9.0.1](https://github.com/react-native-device-info/react-native-device-info/compare/v9.0.0...v9.0.1) (2022-06-04) ### Bug Fixes * **web:** Illegal invocation fro... — committed to react-native-device-info/react-native-device-info by semantic-release-bot 2 years ago
- chore(release): 9.0.1 [skip ci] ## [9.0.1](https://github.com/react-native-device-info/react-native-device-info/compare/v9.0.0...v9.0.1) (2022-06-04) ### Bug Fixes * **web:** Illegal invocation fro... — committed to WictorWilnd/react-native-device-info by WictorWilnd 10 months ago
@Njaah-0 for me its yandex metrika: https://mc.yandex.ru/metrika/tag.js
Issue still happening on react-native-device-info: ^10.4.0
🎉 This issue has been resolved in version 9.0.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
It would seem that my patch based on https://github.com/react-native-device-info/react-native-device-info/pull/1333 didn’t affect the error appearance rate, it’s still happening.
Yeah, I probably shouldn’t 😆 but I really hate bugs. I really love fixing them though, and I extra-love it when anyone else helps fix bugs, it’s how the whole thing (react-native ecosystem) moves forward…
I’ve linked a PR @mikehardy (btw you seem to be working on every repo I use, RNfirebase, device-info… ^^)