Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get response from Private URL using fetch from BlackBerry-Dynamics-for-React-Native-Networking #17

Open
tanujchawla opened this issue Apr 3, 2021 · 0 comments

Comments

@tanujchawla
Copy link

tanujchawla commented Apr 3, 2021

Here is my code snippet

import { fetch } from 'BlackBerry-Dynamics-for-React-Native-Networking';

async componentDidMount() {
    try {

      let res = await fetch('http://my-private-url.com',
      {
         method : 'GET',
         headers : {}
      });
      
      let response = await res.text();
      // let response = await res.json(); // tried this method as well, getting same behaviour
      
    } catch (error) {
      console.log('errr-----', error);
    }
  }

I am getting the following error sometimes and sometimes it works fine (Note - on the same API, same response) :-

Error: The specified blob is invalid
    at Object.promiseMethodWrapper [as readAsText] (D:\PE-Code\rester\ds\node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:103)
    at EventTarget.readAsText (D:\PE-Code\rester\ds\node_modules\BlackBerry-Dynamics-for-React-Native-Networking\js\FileReader.js:118)
    at readBlobAsText (D:\PE-Code\rester\ds\node_modules\BlackBerry-Dynamics-for-React-Native-Networking\js\fetch.js:206)
    at Response.Body.text (D:\PE-Code\rester\ds\node_modules\BlackBerry-Dynamics-for-React-Native-Networking\js\fetch.js:300)
    at RootDashboard.componentDidMount$ (D:\PE-Code\rester\ds\src\components\dashboards\RootDashboard.js:48)
    at tryCatch (D:\PE-Code\rester\ds\node_modules\regenerator-runtime\runtime.js:63)
    at Generator.invoke [as _invoke] (D:\PE-Code\rester\ds\node_modules\regenerator-runtime\runtime.js:293)
    at Generator.next (D:\PE-Code\rester\ds\node_modules\regenerator-runtime\runtime.js:118)
    at tryCatch (D:\PE-Code\rester\ds\node_modules\regenerator-runtime\runtime.js:63)
    at invoke (D:\PE-Code\rester\ds\node_modules\regenerator-runtime\runtime.js:154)

Can you help me by suggesting what I might be doing wrong?
Am I using the fetch from BlackBerry-Dynamics-for-React-Native-Networking correctly?

React Native Version - 0.63.4,
BB Dynamics SDK version - 8.1

Sometimes it works fine, sometimes it gives error.

I am making 3-4 API requests at the time of loading of my application, sometimes the 3rd request fails, sometimes the 1st one fails and happens like this randomly.

I logged the xhr before this line - https://github.com/blackberry/BlackBerry-Dynamics-React-Native-SDK/blob/master/modules/BlackBerry-Dynamics-for-React-Native-Networking/js/fetch.js#L483

Some of my findings which tell me whether I got a successful response or not -

  1. The blob size when we get successful response is significantly greater (around 1200) than when we get an error response (around 50) on the same API, same response.

  2. When I get a successful response, the responseURL is correct but when I don't get a successful response, the responseURL is - "http://10.0.2.2:8081/symbolicate".

  3. Also, most of the times, I get an error on the first time my app is loaded after going through the BB authorization screens. It works fine most of the times after I refresh my app.

XHR when I get a successful response -
18

XHR when I get error -
17

Do these findings help in any way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant