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.

_runNativeCommand called with wrong arguments

See original GitHub issue

Describe the bug On Android I’m getting warning that TypeError: args.unshift is not a function.

I investigated, and and found that NativeBridgeComponent calls _runNativeCommand with three arguments here in _runPendingNativeCommands.

MapView overrides _runNativeCommand here and will treat nativeRef as args, which is wrong.

I’m using latest master branch.

To Reproduce

Not needed, as the bug us clearly in the code.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • Platfrom: [e.g. Android, iOS]
  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • SDK Version [e.g. 22]
  • React Native Version [e.g. 0.59]

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ShepelEcommented, Aug 20, 2019

Hi! maps/javascript/components/NativeBridgeComponent:64 it accepts the args, but args is not an array, it’s a similar structure and it doesn’t have unshift method so change the block to:

      if (isAndroid()) {
        // https://github.com/react-native-mapbox-gl/maps/issues/326
        // TypeError: args.unshift is not a function
        // fix: args is not an array, so need to perform it into real array
        const _args = [];
        for (let i=0; i<args.length; i++) {
          _args.push(args[i]);
        }

        return new Promise(resolve => {
          callbackIncrement += 1;
          const callbackID = `${methodName}_${callbackIncrement}`;
          this._addAddAndroidCallback(callbackID, resolve);
          _args.unshift(callbackID);
          runNativeCommand(this._nativeModuleName, methodName, nativeRef, _args);
        });
      }
0reactions
makirbycommented, Aug 22, 2019

Yeah apologies the class work makes no difference. Yeah that’s the flow that II observed when I was debugging this the other day.

I went with a simple rename patch just like #272 which is running in production for us now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

_runNativeCommand called with wrong arguments · Issue ...
On Android I'm getting warning that TypeError: args.unshift is not a function . I investigated, and and found that NativeBridgeComponent calls ...
Read more >
Python: reason for TypeError with wrong number of arguments
NOTE: I understand why an error is raised for a call with the wrong number of arguments, I definitely want that!
Read more >
Debugger output says an event was called with wrong number ...
I'm working in a brown field project (inherited code of questionable quality), an Azure website with a few workers. When debugging locally I ......
Read more >
wrong number or types of arguments in call to X?
1 Answer 1 ... This: DECLARE TYPE studId_scholarshipModification IS RECORD(studentID studenti.id%TYPE, modificationPercentage NUMBER); TYPE ...
Read more >
Error: Wrong number of arguments: (3 . 4), 2 - Reddit
I get an error for many packages saying: Error: Wrong number… ... (defmacro define-obsolete-function-alias ( obsolete-name current-name when &optional ...
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