question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Illegal invocation from getBattery call

See original GitHub issue

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. Screenshot 2021-04-21 at 9 24 22

Expected behavior

If getBattery call is found from navigator, call should not give error and no call should happen if method is not supported.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ZerdoX-xcommented, Jul 22, 2021

@Njaah-0 for me its yandex metrika: https://mc.yandex.ru/metrika/tag.js

1reaction
Njaah-0commented, Jan 24, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Uncaught TypeError: Illegal invocation" in Chrome
In your code you are assigning a native method to a property of custom object. When you call support.animationFrame(function () {}) , it...
Read more >
Navigator.getBattery() - Web APIs | MDN
The getBattery() method provides information about the system's battery. It returns a battery promise, which is resolved in a BatteryManager ...
Read more >
react-native-device-info 9.0.1 on Node.js Yarn - NewReleases.io
web: Illegal invocation from getBattery call (#1333) (77dcf2c), closes #1223. Check out latest releases or releases around react-native-device-info 9.0.1.
Read more >
Illegal invocation caused by sendBeacon() call in gtag.js ...
Summary: I am getting a lot of errors reports on Sentry from gtag.js that look like the following: TypeError: Illegal invocation at GB(/gtag/js:385:23)...
Read more >
react-native-device-info - Bountysource
This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found