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

@redux-offline Detect network getConnectionInfo of undefined #443

Closed
ulziiburend opened this issue Jul 23, 2019 · 46 comments
Closed

@redux-offline Detect network getConnectionInfo of undefined #443

ulziiburend opened this issue Jul 23, 2019 · 46 comments

Comments

@ulziiburend
Copy link

Hello. I am using the latest version of React Native and Aws AppSync. And I've got deprecation issue on @redux-offline dependency.
Maybe you want to see my implementation

import Amplify, { Auth } from 'aws-amplify';
import awsconfig from './aws-exports';
import AWSAppSyncClient from 'aws-appsync'
import { Rehydrated } from 'aws-appsync-react'
import { ApolloProvider } from 'react-apollo'
Amplify.configure(awsconfig);

const client = new AWSAppSyncClient({
    url: config.aws_appsync_graphqlEndpoint,
    region: config.aws_appsync_region,
    auth: {
      type: config.aws_appsync_authenticationType,
      jwtToken: async () => (await Auth.currentSession()).idToken.jwtToken
    }
  });
const AppWithProvider = () => (
    <ApolloProvider client={client}>
      <Rehydrated
        render={({ rehydrated }) => (
          rehydrated ? <App /> : <SplashScreen />
        )}
      />
    </ApolloProvider>
  );
AppRegistry.registerComponent(appName, () => AppWithProvider);

According to this link https://github.com/react-native-community/react-native-netinfo this method is already deprecated.
Could you help me round to solve this issue?

@ulziiburend
Copy link
Author

Maybe it would be helpful
redux-offline/redux-offline#339 (comment)

@usmansbk
Copy link

All that is needed to fix this is to update the package.json to @redux-offline dependency to 2.5.2-native.0. Almost feels like it's taking too long to fix.

@amie-wilt
Copy link

Sorry to be annoying and add to the noise but I've been monitoring this like crazy as it's a bit of a blocker for me. Why is this taking so long?

@ulziiburend
Copy link
Author

@usmansbk @amie-wilt hey guys I have noticed that these guys not gonna update libraries and I downgraded my react-native to 0.58.4 and here are my dependencies

  "@react-native-community/async-storage": "^1.6.1",
    "aws-amplify": "^1.1.32",
    "aws-amplify-react-native": "^2.1.15",
    "aws-appsync": "^1.8.1",
    "aws-appsync-react": "^1.2.9",
    "mobx": "^5.13.0",
    "mobx-react": "^6.1.1",
    "native-base": "^2.12.2",
    "react": "16.6.3",
    "react-apollo": "^2.3.3",
    "react-native": "0.58.4",

and now everything works fine

@amie-wilt
Copy link

amie-wilt commented Jul 26, 2019

Thanks @ulziiburend but unfortunately I have no intentions of downgrading from RN0.60.x.

@cmmouritsen
Copy link

While I wait for the official fix, I have fixed this for my project by adding this to my package.json:

"resolutions": {
    "@redux-offline/redux-offline": "2.5.2-native.0"
}

It forces all of my dependencies to use that version of the @redux-offline/redux-offline package.

@amie-wilt
Copy link

@cmmouritsen Whoa that's amazing! I never knew! Thank you!

@usmansbk
Copy link

@cmmouritsen Thanks. Is there way to patch the aws-appsync-react Rehydrated component without modifying the node_modules?

@bernhardt1
Copy link

@cmmouritsen

I added the resolution but I'm still seeing the issue.

I tried updating the dependency inside aws-appsync/package.json to "@redux-offline/redux-offline": "2.5.2-native.0" as well but still getting the same.

Also tried npm start -- --reset-cache (thought it might not be catching the change)

any advice on why that solution wouldn't be fixing the issue?

@usmansbk
Copy link

@bernhardt1 add the resolutions to your project's package.json file then npm install aws-appsync again

@cmmouritsen
Copy link

cmmouritsen commented Jul 26, 2019

Thanks. Is there way to patch the aws-appsync-react Rehydrated component without modifying the node_modules?

@usmansbk I can't think of a way.

I added the resolution but I'm still seeing the issue.

I tried updating the dependency inside aws-appsync/package.json to "@redux-offline/redux-offline": "2.5.2-native.0" as well but still getting the same.

Also tried npm start -- --reset-cache (thought it might not be catching the change)

any advice on why that solution wouldn't be fixing the issue?

@bernhardt1 As @usmansbk mentioned, you have to install the package again after making the change to your package.json. Because of that, I don't know that it would work to change the aws-appsync/package.json directly. I don't know if it's relevant, but I am using yarn rather than npm.

@bernhardt1
Copy link

incase other have trouble with the solution by #443 (comment) - try this

npm was part of the issue for me. Their resolutions tool failed to force resolutions https://www.npmjs.com/package/npm-force-resolutions

I switched back to yarn and @redux-offline is now forced to native 2.5.2 as expected. (using #443 (comment))

The last error was the netinfo dependency itself. I had to add the package as described in their docs: https://github.com/react-native-community/react-native-netinfo

@amie-wilt
Copy link

amie-wilt commented Jul 29, 2019

@manueliglesias First and foremost, thank you for you contributions to this project.

I noticed you responded to @cmmouritsen's comment with a rocket emoji, and therefore I can safely assume you've seen this issue. As @usmansbk pointed out, the Rehydrated component breaks due to an old import of NetInfo from "react-native" rather than "@react-native-community/netinfo". Is there any intent to update this package to work with RN 0.60.x any time soon?

I'm beginning to worry given the delays on this and the lack of Apollo client update (#369) that this package is going to stop being maintained at some point in the near future. Is that a possibility?

I understand the Apollo client update may be more than just a couple lines but it seems this particular update is rather straightforward and has PRs in the works ready to be reviewed/merged so the lack of activity on this is becoming rather concerning. Please advise.

Thank you.

#434
#445

@bernhardt1
Copy link

bernhardt1 commented Jul 29, 2019

Also linking @elorzafe @manueliglesias TLDR; Piggybacking off of @amie-wilt - concerned about maintenance & future of Appsync. Can we expect continued updates & maintenance of this package and Appsync for the next few years?

I spent a day last week upgrading from RN 0.59.x -> 0.60.x and this library is blocking the completion of that upgrade. It is worrisome to see the lack of activity from the major contributors...

I've been using Appsync in my project for the last year & am currently entering beta testing. Obviously I hope to continue using the service, but I would love some information about its future. Will Amazon continue to support it & maintain the packages that support it?

@manueliglesias
Copy link
Contributor

manueliglesias commented Jul 29, 2019

Hi,

Thank you for the patience, we are actively working on unblocking this and wanted to have a concrete implementation plan before responding. At the very least, giving an option when instantiating the client to override the network detection mechanism so consumers can pass one that e.g. uses @react-native-community/netinfo.

It will look something like this:

import detectNetwork from "path/to/copy/of/defaults/detectNetwork.native.js"; // Taken from https://github.com/redux-offline/redux-offline/blob/native/src/defaults/detectNetwork.native.js

const client = new AWSAppSyncClient({
	// ...
	offlineConfig: {
		detectNetwork: detectNetwork
	}
});

We would like to publish a version with this pattern to an unstable dist tag in the following days, hopefully you can help us test it before releasing it to a broader audience.

@vadiraja
Copy link

vadiraja commented Aug 2, 2019

SDK maintainers are not realizing that it is causing business loss to AWS. People are not getting into App Sync and other services because of this lackluster response. I am seriously consider should I invest in AWS technologies / eco system

@undefobj
Copy link
Contributor

undefobj commented Aug 2, 2019

@vadiraja we are very aware of the issue and @manueliglesias is one of the maintainers and commented 3 days back. While we could have commented earlier, we've been focusing on solving this and it took a bit of research as well as discussion with some OSS community members and RN team. That being said we had people working on this with progress even today and are optimistically looking to provide a solution early next week.

@QuangChien-NTQ-NS6
Copy link

waiting........ :(((

@VicFrolov
Copy link

Thanks for the update @undefobj, happy a release is coming this week!

@QuangChien-NTQ-NS6
Copy link

@undefobj I miss you ..... =)))

@Ashish-Nanda
Copy link
Contributor

Hi,

Thanks for your patience. We have been actively working on fixing this issue and are testing the changes at this time. We plan to release this soon, and will publish it to an unstable tag initially and look forward to your help in testing it further. Thank you.

@Ashish-Nanda
Copy link
Contributor

Hi,

We have just released an unstable version that fixes this issue under the unstable-native tag for you to use and help us test before we publish to the latest tag.

To try it out, you can do:

yarn add -E aws-appsync@unstable-native aws-appsync-react@unstable-native

You would need to also install react-native-community/netinfo

yarn add @react-native-community/netinfo

@VicFrolov
Copy link

Hi @Ashish5591 just checking in on progress for a stable build. I noticed I was receiving unhandled promise warnings for users that were not signed in (but should have access to content). The data loads fine, but I get that warning.

@norby3
Copy link

norby3 commented Aug 18, 2019

@Ashish5591 unstable fix above worked - but i'm on RN 0.60 and had to cd into ios dir and run 'pod install' which gave a message: Installing react-native-netinfo (4.1.5)

@Ashish-Nanda
Copy link
Contributor

Ashish-Nanda commented Aug 19, 2019

@VicFrolov We were waiting a while so that people in the community have time to test the changes and report issues if any. That said, we plan to release a stable version with these changes sometime this week. Could you give more info regarding the unhandled promise warnings?

@norby3 I think running pod install from the ios dir is an expected step in RN 0.60 when linking dependencies.

@tmjordan
Copy link

@Ashish5591 @norby3 @VicFrolov Hi guys, i just installed the unstable release of aws-appsync in order to fix the current issue. It seems to work, but i have another error:
The keyPrefix reduxPersist: is already in use. Multiple clients cannot share the same keyPrefix. Provide a different keyPrefix in the offlineConfig object.

@matthamil
Copy link

@Ashish5591 is there a newsletter/email list/etc for updates from the AppSync team on unstable releases like this that you all are wanting members to test? It would be nice to hear about updates like this through other channels outside of GH issue comments

@Ashish-Nanda
Copy link
Contributor

@matthamil We dont have that at the moment, but its a great suggestion! I agree it would be good to have a centralized way to send updates about AppSync to our customers. I'll bring up the idea of a newsletter with our team as something we should look to do in the future.

@tmjordan I have not seen this issue. Could you share a little bit more about your setup, as well as your package.json file. Maybe opening another issue for it would be better.

@amie-wilt
Copy link

@Ashish5591 I'm not seeing any issues with the unstable version on my end. Are you waiting for more responses before issuing a stable release?

@Ashish-Nanda
Copy link
Contributor

@amie-wilt I agree its relatively stable. However since this change is not backwards compatible, we are evaluating how we want to support RN <0.60 in the future. Once the team reaches a decision on that, we will do a stable release.

@amie-wilt
Copy link

amie-wilt commented Aug 28, 2019

@Ashish5591 Thanks for the quick response.

  1. Can you estimate a timeline for when a decision might be made?

  2. How strongly do you advise against using the unstable version in a production app?

Thank you.

@sorodrigo
Copy link

At redux offline we released a new native version native.1 this removes the async storage and instead expects user to install the one from react-native-community (same as with net-info).

@Ashish-Nanda
Copy link
Contributor

@amie-wilt We just released a new version (2.0.0) for the AppSync SDK which supports React Native 0.60. Please give it a try with your app and let us know if everything works as expected.

@sorodrigo Thanks for the update. We are using native.0 as of now, but will test native.1 and upgrade in the next release.

@amie-wilt
Copy link

That’s wonderful @Ashish5591! Will do, thanks!

@norby3
Copy link

norby3 commented Sep 8, 2019

Struggling to get RN 0.60 app working with aws-appsync 2.0.0.
Do we still need to add @react-native-community/netinfo ??

Error msg:
Unable to resolve module @react-native-community/netinfo from /Users/ xxx/xxx/xxx/AnnTestAppSync/node_modules/aws-appsync-react/lib/rehydrated-rn.js: Module @react-native-community/netinfo does not exist in the Haste module map

@matthamil
Copy link

@norby3 looks like it's a peerDependency:

"@react-native-community/netinfo": "4.x.x",
.

This could probably be added to the yarn add command in the README for those using React Native:

yarn add aws-appsync @react-native-community/net-info

@norby3
Copy link

norby3 commented Sep 9, 2019

thanks @matthamil - guess it is true of all code documentation - never quite in sync with the code - i'm guilty of this on my projects.

@norby3
Copy link

norby3 commented Sep 10, 2019

hi - following up - the root cause / fix for my RN 0.60 app seems to be to use [email protected] and not the latest / default [email protected]

  "dependencies": {
    "@react-native-community/netinfo": "^4.2.1",
    "apollo-client": "^2.6.4",
    "aws-appsync": "^2.0.0",
    "aws-appsync-react": "^2.0.0",
    "graphql": "^14.5.4",
    "react": "16.8.6",
    "react-apollo": "2.5.7",
    "react-dom": "^16.9.0",
    "react-native": "0.60.5"

i also had to change my mindset to pay more attention to dependencies and version - and not assume yarn will figure it out

@Ashish-Nanda
Copy link
Contributor

@norby3 Yes, we have a peer dependency on "react-apollo": "2.x" and are aware about issues with 3.x
@matthamil Thanks for the suggestion. I've updated the documentation with setup instructions for RN 0.60

Closing this issue now, as AWS AppSync SDK v2.00 supports RN 0.60 and the documentation has been updated as well.

@anupgusain
Copy link

Hi friend quick fix for Net Info error with redux offline
use redux-offline version @redux-offline/redux-offline: "2.5.2-native.0"

and if you get error handler is not a function, handler is "change" then use
@react-native-community/netinfo: "4.7.0"

read #339 (comment) of @sorodrigo

@jitendra-koodo
Copy link

jitendra-koodo commented Jan 31, 2020

@norby3 Yes, we have a peer dependency on "react-apollo": "2.x" and are aware about issues with 3.x
@matthamil Thanks for the suggestion. I've updated the documentation with setup instructions for RN 0.60

Closing this issue now, as AWS AppSync SDK v2.00 supports RN 0.60 and the documentation has been updated as well.

Which document are we talking about here? Link please....

Still getting this error :

Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module @react-native-community/netinfo from node_modules\aws-appsync-react\lib\rehydrated-rn.js: @react-native-community/netinfo could not be found within the project.

OS: windows 10

"dependencies": {
"aws-amplify": "^2.2.2",
"aws-amplify-react-native": "^3.2.0",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"graphql-tag": "^2.10.1",
"react": "16.9.0",
"react-apollo": "^3.1.3",
"react-native": "0.61.5"
},

@jitendra-koodo
Copy link

jitendra-koodo commented Jan 31, 2020

@norby3 Yes, we have a peer dependency on "react-apollo": "2.x" and are aware about issues with 3.x
@matthamil Thanks for the suggestion. I've updated the documentation with setup instructions for RN 0.60
Closing this issue now, as AWS AppSync SDK v2.00 supports RN 0.60 and the documentation has been updated as well.

Which document are we talking about here? Link please....

Still getting this error :

Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module @react-native-community/netinfo from node_modules\aws-appsync-react\lib\rehydrated-rn.js: @react-native-community/netinfo could not be found within the project.

OS: windows 10

"dependencies": {
"aws-amplify": "^2.2.2",
"aws-amplify-react-native": "^3.2.0",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"graphql-tag": "^2.10.1",
"react": "16.9.0",
"react-apollo": "^3.1.3",
"react-native": "0.61.5"
},

ok, sorry. I had to explicit install @react-native-community/netinfo . This problem is gone. But other problems are cropping up.

@jitendra-koodo
Copy link

Very frustrating.. nothing works in Appsync if we follow docs.. we are wasting time on fixing these rather than focusing on product.

Guys, Is there any working configuration for "react-native": "0.61.5" ? I'm ok to downgrade dependencies versions to save time and frustration...

@manusharian
Copy link

Hi,
I do believe that this problem resurfaced in latest SDK of Expo, SDK 37.
With this packages (some of them that we think are of interest):

{
"@react-native-community/netinfo": "5.5.0",
"@redux-offline/redux-offline": "^2.5.2-native.3",
"apollo-client": "^2.6.8",
"aws-amplify": "^3.0.4",
"aws-amplify-react-native": "^4.0.2",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"react": "^16.13.1",
"react-apollo": "^2.5.8",
"react-native": "0.61.5",
"aws-sdk": "^2.651.0",
},

Screenshot 2020-04-02 at 22 06 49
Screenshot 2020-04-02 at 22 07 02
Screenshot 2020-04-02 at 22 07 14

These are the warnings we receive. Not very sure what are the packages involved in this, we tried with different versions of react-native, react, aws-amplify (also by using the destructured packages as core, auth, storage). Also I may also point out that the react-apollo 2.x dependency still exists and there is nothing about integrating appsync with react-apollo 3.x. For the moment we will go back to sdk 36
Thank you and sorry if this is not the correct thread!

@adib85
Copy link

adib85 commented May 4, 2020

Hi,
I do believe that this problem resurfaced in latest SDK of Expo, SDK 37.
With this packages (some of them that we think are of interest):

{
"@react-native-community/netinfo": "5.5.0",
"@redux-offline/redux-offline": "^2.5.2-native.3",
"apollo-client": "^2.6.8",
"aws-amplify": "^3.0.4",
"aws-amplify-react-native": "^4.0.2",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"react": "^16.13.1",
"react-apollo": "^2.5.8",
"react-native": "0.61.5",
"aws-sdk": "^2.651.0",
},

Screenshot 2020-04-02 at 22 06 49
Screenshot 2020-04-02 at 22 07 02
Screenshot 2020-04-02 at 22 07 14

These are the warnings we receive. Not very sure what are the packages involved in this, we tried with different versions of react-native, react, aws-amplify (also by using the destructured packages as core, auth, storage). Also I may also point out that the react-apollo 2.x dependency still exists and there is nothing about integrating appsync with react-apollo 3.x. For the moment we will go back to sdk 36
Thank you and sorry if this is not the correct thread!

Have you found a way to solve this?
I'm having the same warnings using Expo SDK 37. I've also tried with different versions and no results.

Thank you.

@manusharian
Copy link

manusharian commented May 4, 2020

Hi,
I do believe that this problem resurfaced in latest SDK of Expo, SDK 37.
With this packages (some of them that we think are of interest):

{
"@react-native-community/netinfo": "5.5.0",
"@redux-offline/redux-offline": "^2.5.2-native.3",
"apollo-client": "^2.6.8",
"aws-amplify": "^3.0.4",
"aws-amplify-react-native": "^4.0.2",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"react": "^16.13.1",
"react-apollo": "^2.5.8",
"react-native": "0.61.5",
"aws-sdk": "^2.651.0",
},

Screenshot 2020-04-02 at 22 06 49
Screenshot 2020-04-02 at 22 07 02
Screenshot 2020-04-02 at 22 07 14
These are the warnings we receive. Not very sure what are the packages involved in this, we tried with different versions of react-native, react, aws-amplify (also by using the destructured packages as core, auth, storage). Also I may also point out that the react-apollo 2.x dependency still exists and there is nothing about integrating appsync with react-apollo 3.x. For the moment we will go back to sdk 36
Thank you and sorry if this is not the correct thread!

Have you found a way to solve this?
I'm having the same warnings using Expo SDK 37. I've also tried with different versions and no results.

Thank you.

Yes, I just followed this tutorial.
I upgraded expo sdk to 37 with expo upgrade, then I updated all packages from aws and apollo, then I followed the tutorial for setting up my App.js file.
Now everything works ok.
Some of my packages:

{
   "@apollo/react-common": "^3.1.4",
    "@aws-amplify/auth": "^3.2.6",
    "@aws-amplify/storage": "^3.1.9",
    "@react-native-community/netinfo": "5.5.1",
    "apollo-cache-inmemory": "^1.6.5",
    "apollo-client": "^2.6.8",
    "apollo-link": "^1.2.14",
    "aws-amplify": "^3.0.10",
    "aws-amplify-react-native": "^4.1.1",
    "aws-appsync": "^3.0.3",
    "aws-appsync-auth-link": "^2.0.2",
    "aws-appsync-react": "^3.0.3",
    "aws-appsync-subscription-link": "^2.1.0",
    "aws-sdk": "^2.668.0",
    "expo": "^37.0.0",
    "react": "^16.13.1",
    "react-apollo": "^3.1.5",
    "react-native": "^0.61.4",
    "redux": "^4.0.5",
},

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