-
Notifications
You must be signed in to change notification settings - Fork 266
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
React 18 subscriptions failing #722
Comments
Possible duplicate of #509 |
I am experiencing this issue only when using StrictMode. The following effect is run twice because of StrictMode. useEffect(() => {
console.log("useEffect");
const unsubscribe = subscribeToMore({
document: BASIC_SUBSCRIPTION,
onError: console.error,
updateQuery: (prev, { subscriptionData }) => {
//
},
});
return () => {
console.log("cleanup");
unsubscribe();
};
}, [subscribeToMore]); When I disable StrictMode, I no longer have the error. I am using versions: "@apollo/client": "^3.6.9",
"aws-appsync-auth-link": "^3.0.7",
"aws-appsync-subscription-link": "^3.1.0", I guess this should work without an error, even in StrictMode? |
I'll try this on my end and see if it works @Stijnkool |
@Stijnkool that was it! I'm using |
@jmparsons Thanks for this issue we are having the exact same troubles. |
@Hideman85 I'd need to test it out myself with strict mode on. We use |
@Hideman85 as far as I know, this has not been fixed. I still get the error. But I guess it should not happen in production because strictmode is disabled in that scenario. But this error should not be thrown even with strictmode on. So no fix at the moment I think. |
Having the same issue in nextjs with both strictmode on and off. |
@pehel after you change strict mode: /** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: false,
}; Restart your app from the cli. See if it works then, I had to restart it myself. |
This hack worked for me. It wont add data to cache as well as it will block invoking useEffect twice |
The
useSubscription
hook using React 18 results insubscriptionFailedCallback
.Line throwing error here:
https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/master/packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts#L336
I've tried non strict already and also the alpha 3.7 of apollo client, same undefined failed callback.
Possibly related to:
apollographql/apollo-client#7608
The text was updated successfully, but these errors were encountered: