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.

Invariant Violation: [14,"<<-Infinity>>",1573709572775,false] is not usable as a native method argument

See original GitHub issue

I’m using snoowrap in react native, and got the module to import without errors by importing the required modules according to @danhab99 here https://github.com/not-an-aardvark/snoowrap/issues/48#issuecomment-417948299

I ended up with this package.json

{
  "name": "myapp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "events": "^3.0.0",
    "fs": "0.0.1-security",
    "path": "^0.12.7",
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-gesture-handler": "^1.5.0",
    "react-navigation": "^4.0.10",
    "react-navigation-stack": "^1.10.3",
    "rxjs": "^6.5.3",
    "snoowrap": "^1.20.0",
    "stream": "0.0.2",
    "url": "^0.11.0",
    "util": "^0.12.1"
  },
  "devDependencies": {
    "@babel/core": "7.6.4",
    "@babel/runtime": "7.6.3",
    "@react-native-community/eslint-config": "0.0.3",
    "babel-jest": "24.9.0",
    "eslint": "^5.16.0",
    "jest": "24.9.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

My snoowrap object is instanced successfully with these params

import snoowrap from 'snoowrap';
// later in componentDidMount
const r = new snoowrap({
            userAgent: 'RedditAgent',
            clientId: 'my-id',
            clientSecret: 'my-secret',
            refreshToken: 'my-token',
        });
r.config({debug: true, proxies: false});
console.log('getting hot', r);
r.getHot('AskReddit', {limit: 100}).then(res => console.log('res', res)).catch(err => console.error(err));

I get the following output.

2019-11-14 00:40:48.291 [info][tid:com.facebook.react.JavaScript] 'getting hot', { userAgent: 'Redditagent',
  clientId: 'id',
  clientSecret: 'secret',
  refreshToken: 'token',
  accessToken: null,
  username: null,
  password: null,
  ratelimitRemaining: null,
  ratelimitExpiration: null,
  tokenExpiration: null,
  scope: null,
  _config: 
   { endpointDomain: 'reddit.com',
     requestDelay: 0,
     requestTimeout: 30000,
     continueAfterRatelimitError: false,
     retryErrorCodes: [ 502, 503, 504, 522 ],
     maxRetryAttempts: 3,
     warnings: true,
     debug: true,
     proxies: false },
  _nextRequestTimestamp: -Infinity }
2019-11-14 00:40:48.295 [error][tid:com.facebook.react.JavaScript] Invariant Violation: [24,"<<-Infinity>>",1573710048293,false] is not usable as a native method argument
2019-11-14 00:40:48.302 [warn][tid:com.facebook.react.JavaScript] '%cUnhandled rejection Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.\n\n[[33,37],[0,0],[["Invariant Violation: [24,\\"<<-Infinity>>\\",1573710048293,false] is not usable as a native method argument",[{"column":20,"lineNumber":2554,"arguments":[],"methodName":"enqueueNativeCall","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":42,"lineNumber":2164,"arguments":[],"methodName":"fn","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":38,"lineNumber":30898,"arguments":[],"methodName":"createTimer","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":18,"lineNumber":30706,"arguments":[],"methodName":"setTimeout","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":17,"lineNumber":30620,"arguments":[],"methodName":"_callTimer","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":19,"lineNumber":30656,"arguments":[],"methodName":"_callImmediatesPass","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":33,"lineNumber":30875,"arguments":[],"methodName":"callImmediates","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":null,"lineNumber":null,"arguments":[],"methodName":"callImmediates","file":"[native code]"},{"column":35,"lineNumber":2624,"arguments":[],"methodName":"__callImmediates","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":15,"lineNumber":2607,"arguments":[],"methodName":"__guard","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":21,"lineNumber":2400,"arguments":[],"methodName":"flushedQueue","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":null,"lineNumber":null,"arguments":[],"methodName":"flushedQueue","file":"[native code]"},{"column":12,"lineNumber":125207,"arguments":[],"methodName":"oauthRequest","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":36,"lineNumber":127674,"arguments":[],"methodName":"_fetchMoreRegular","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":113,"lineNumber":127659,"arguments":[],"methodName":"fetchMore","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":17,"lineNumber":59,"arguments":[],"methodName":"componentDidMount","file":"http://localhost:8081/src/home/HomeList.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true"},{"column":45,"lineNumber":24177,"arguments":[],"methodName":"commitLifeCycles","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":29,"lineNumber":26521,"arguments":[],"methodName":"commitLayoutEffects","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":21,"lineNumber":12661,"arguments":[],"methodName":"invokeGuardedCallbackImpl","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":42,"lineNumber":12757,"arguments":[],"methodName":"invokeGuardedCallback","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":36,"lineNumber":26328,"arguments":[],"methodName":"commitRootImpl","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":null,"lineNumber":null,"arguments":[],"methodName":"commitRootImpl","file":"[native code]"},{"column":30,"lineNumber":42641,"arguments":[],"methodName":"unstable_runWithPriority","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":24,"lineNumber":26190,"arguments":[],"methodName":"commitRoot","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":null,"lineNumber":null,"arguments":[],"methodName":"commitRoot","file":"[native code]"},{"column":34,"lineNumber":25523,"arguments":[],"methodName":"runRootCallback","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":null,"lineNumber":null,"arguments":[],"methodName":"runRootCallback","file":"[native code]"},{"column":30,"lineNumber":42641,"arguments":[],"methodName":"unstable_runWithPriority","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":28,"lineNumber":16248,"arguments":[],"methodName":"flushSyncCallbackQueueImpl","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":35,"lineNumber":16237,"arguments":[],"methodName":"flushSyncCallbackQueue","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":33,"lineNumber":25641,"arguments":[],"methodName":"flushSync","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":20,"lineNumber":16788,"arguments":[],"methodName":"scheduleRefresh","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":null,"lineNumber":null,"arguments":[],"methodName":"forEach","file":"[native code]"},{"column":31,"lineNumber":41052,"arguments":[],"methodName":"performReactRefresh","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":48,"lineNumber":40842,"arguments":[],"methodName":"performReactRefresh","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":17,"lineNumber":30620,"arguments":[],"methodName":"_callTimer","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":19,"lineNumber":30827,"arguments":[],"methodName":"callTimers","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":49,"lineNumber":2653,"arguments":[],"methodName":"__callFunction","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":15,"lineNumber":2607,"arguments":[],"methodName":"__guard","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":21,"lineNumber":2365,"arguments":[],"methodName":"callFunctionReturnFlushedQueue","file":"http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false"},{"column":null,"lineNumber":null,"arguments":[],"methodName":"callFunctionReturnFlushedQueue","file":"[native code]"}],2]],418]\n    enqueueNativeCall@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2566:43\n    fn@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2164:42\n    reportSoftException@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28984:39\n    reportException@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:29003:46\n    reportException@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28780:46\n    reactConsoleErrorHandler@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:28838:22\n    error@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:67347:29\n    _callTimer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30620:17\n    _callImmediatesPass@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30656:19\n    callImmediates@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30875:33\n    callImmediates@[native code]\n    __callImmediates@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2624:35\n    __guard@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2607:15\n    flushedQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2400:21\n    flushedQueue@[native code]\nFrom previous event:\n    componentDidMount@http://localhost:8081/src/home/HomeList.bundle?platform=ios&dev=true&minify=false&modulesOnly=true&runModule=false&shallow=true:63:17\n    commitLifeCycles@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:24177:45\n    commitLayoutEffects@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26521:29\n    invokeGuardedCallbackImpl@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:12661:21\n    invokeGuardedCallback@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:12757:42\n    commitRootImpl@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26328:36\n    commitRootImpl@[native code]\n    unstable_runWithPriority@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:42641:30\n    commitRoot@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:26190:24\n    commitRoot@[native code]\n    runRootCallback@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25523:34\n    runRootCallback@[native code]\n    unstable_runWithPriority@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:42641:30\n    flushSyncCallbackQueueImpl@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:16248:28\n    flushSyncCallbackQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:16237:35\n    flushSync@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:25641:33\n    scheduleRefresh@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:16788:20\n    forEach@[native code]\n    performReactRefresh@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:41052:31\n    performReactRefresh@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:40842:48\n    _callTimer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30620:17\n    callTimers@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:30827:19\n    __callFunction@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2653:49\n    __guard@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2607:15\n    callFunctionReturnFlushedQueue@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:2365:21\n    callFunctionReturnFlushedQueue@[native code]', 'color: red'

iPhone XR simulator running iOS 12.2

I think this might be related to the snoowrap printed property _nextRequestTimestamp: -Infinity, but I’ve been on this a few days and I’m not sure what else to try. Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
bibyzancommented, Nov 16, 2019

I was able to resolve the error by adding

r._nextRequestTimestamp = -1;

and then

npm i -S base-64

and then adding these lines at the top of my project index.js

import {decode, encode} from 'base-64'

if (!global.btoa) {
    global.btoa = encode;
}

if (!global.atob) {
    global.atob = decode;
}

And I finally have some json data to work with! Thanks so much!!

1reaction
SpyTeccommented, Nov 15, 2019

That is a normal JavaScript function, which you can google for help as it’s not so specific to snoowrap. Try this https://stackoverflow.com/a/51525605

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: is not usable as a native method argument ...
@xgenem i'm using the StyleSheet, my code was this: fieldTextStyle: { width: "100%", backgroundColor: colors.backgroundTextInput, height: 1, ...
Read more >
React Native, 'is not usable as a native method argument'
I encountered this issue while using Axios with formData field without converting the appended data to string format. Gives errors: const ...
Read more >
React Native, 'is not usable as a native method argument'
Coding example for the question React Native, 'is not usable as a native method argument'-React Native.
Read more >
Common bugs in React Native - Morioh
Invariant Violation : Element type is invalid: expected a string (for ... Check the render method of 'App'. ... is not usable as...
Read more >
Problem setting position of an element with dynamic styling
... Invariant Violation: [27,"RCTView",{"top":-603.3333282470703,"left":-25.333328247070312}] is not usable as a native method argument.
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