Sifir-io / react-native-tor

Tor Daemon and Socks5 client for React Native iOS and Android projects!
MIT License
101 stars 15 forks source link

TypeError: null is not an object (evaluating 'TorBridge.request') #20

Closed AdamTo closed 3 years ago

AdamTo commented 3 years ago

Happens on the tor constructor

const tor = Tor();

Stack trace:

TypeError: null is not an object (evaluating 'TorBridge.request')
- node_modules/react-native/Libraries/LogBox/LogBox.js:148:8 in registerError
- node_modules/react-native/Libraries/LogBox/LogBox.js:59:8 in errorImpl
- node_modules/react-native/Libraries/LogBox/LogBox.js:33:4 in console.error
- node_modules/expo/build/environment/react-native-logs.fx.js:27:4 in error
- node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
- node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
- node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
- node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:9:32 in ErrorUtils.setGlobalHandler$argument_0
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:293:29 in invoke
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:154:27 in invoke
- node_modules/regenerator-runtime/runtime.js:164:18 in PromiseImpl.resolve.then$argument_0
- node_modules/react-native/node_modules/promise/setimmediate/core.js:37:13 in tryCallOne
- node_modules/react-native/node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:181:14 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:441:30 in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:387:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue

Expo error screen. image

NODE: v15.1.0

package.json contents:


{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~40.0.0",
    "expo-status-bar": "~1.0.3",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
    "react-native-tor": "^0.1.5",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0"
  },
  "private": true
}```
AdamTo commented 3 years ago

Hope this is the proper way to contact you guys. It is my first in life issue to open source repo. Your work is great, I search for solution like that for quite some time. Is there a way to contact you guys outside git?

marcosrdz commented 3 years ago

This package contains native modules. I could be wrong but I don't think Expo is able to access native modules. Only pure JS

AdamTo commented 3 years ago

OK. I'll test it natively and update the issue.

AdamTo commented 3 years ago

Have an almost identical situation with pure react native. image

Implementation

const App: () => React$Node = () => {
  const tor = Tor();

  const makeTorRequest = async () => {
    // Start the daemon and socks proxy (no need for Orbot and yes iOS supported!)
    await tor.startIfNotStarted();

    try {
      // Use built in client to make REST calls to .onion urls routed through the Sock5 proxy !
      const resp = await tor.get(
        'http://xmh57jrknzkhv6y3ls3ubitzfqnkrwxhopf5aygthi7d6rplyvk3noyd.onion/cgi-bin/omega/omega',
      );
    } catch (error) {
      // Catch a network or server error like you normally with any other fetch library
    }
  };

  makeTorRequest();
  return (
    <>
      <Text>A</Text>
    </>
  );
};

Do you have some example apps for reference?

gabidi commented 3 years ago

If the error persist, please repost with:

  1. Your package.json
  2. The whole app file to see your imports etc..

Thanks !

AdamTo commented 3 years ago

now works just great, sorry for the inconvenience.