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

Unhandled error Network error #14970

Closed
haris-ramzan opened this issue Jul 12, 2017 · 5 comments
Closed

Unhandled error Network error #14970

haris-ramzan opened this issue Jul 12, 2017 · 5 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@haris-ramzan
Copy link

haris-ramzan commented Jul 12, 2017

Is this a bug?

Unhandled error Network error: Network request failed Error: Network error: Network request failed
at new ApolloError ()

Environment

  1. react-native:0.44.0
  2. react-apollo:1.1.1
  3. apollo-client:1.0.4

Steps to Reproduce

  1. When turn off internet connection.
  2. Render
  3. When turn off internet during app navigation.

Expected Behavior

Component should render without data and errors received through props. The same when its a query error or some kind of http error.

Actual Behavior

The Red screen occur on failure of internet connection with this error "Unhandled error Network error: Network request failed Error: Network error: Network request failed
at new ApolloError ()"

@hramos
Copy link
Contributor

hramos commented Jul 12, 2017

Hey, thanks for reporting this issue!

It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the template? This is necessary for people to be able to understand and reproduce the issue being reported.

I am going to close this, but feel free to open a new issue with the additional information provided. Thanks!

@hramos hramos closed this as completed Jul 12, 2017
@haris-ramzan
Copy link
Author

haris-ramzan commented Jul 20, 2017

@hramos actually i found this error on internet failure during screen navigation with react-native-router-flux.
Here is my Client;

import { AsyncStorage } from 'react-native';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import addGraphQLSubscriptions from '../dev/subscriptions';

const wsClient = new SubscriptionClient('ws://192.168.0.0', {
  reconnect: true,
  connectionParams: {
    accessToken: 'jkasdhkjashd jkashdjk ashdas'
  }
});

const networkInterface = createNetworkInterface({

  uri: 'http://192.168.0.0/graphql',
  opts: {
    credentials: 'same-origin'
  }
});
const logErrors = {
  applyAfterware({ response }, next) {
    if (!response.ok) {
      response.clone().text().then(bodyText => {
        console.error(`Network Error: ${response.status} (${response.statusText}) - ${bodyText}`);
        next();
      });
    } else {
      response.clone().json().then(({ errors }) => {
        if (errors) {
           console.error('GraphQL Errors:', errors.map(e => e.message));
        }
        next();
      });
    }
  },
};
networkInterface.useAfter([logErrors]);
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
  networkInterface,
  wsClient
);
const client = new ApolloClient({
  dataIdFromObject: o => o.id,
  networkInterface: networkInterfaceWithSubscriptions

});
networkInterface.use([{
  applyMiddleware(req, next) {
    if (!req.options.headers) {
      req.options.headers = {};  // Create the header object if needed.
    }
    // get the authentication token from local storage if it exists
    AsyncStorage.getItem('sessionToken').then((token) => {
      req.options.headers.Authorization = token ? `${token}` : null;
      next();
    }
    );
  }
}]);
export default client;

I found this Error "Unhandled error Network error: Network request failed Error: Network error: Network request failed
at new ApolloError"

@haris-ramzan
Copy link
Author

haris-ramzan commented Jul 20, 2017

@hramos Found this Error , screenshot_1499843569

@HPieters
Copy link

@haris-ramzan Did you ever resolve this issue?

@ICCanche
Copy link

Same here.

"react-apollo": "2.0.4",
"react-native": "0.52.0",

@facebook facebook locked as resolved and limited conversation to collaborators Jul 12, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants