JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
919
stars
266
forks
source link
Failures to create subscriptions when using default aws-appsync-subscription-link are not propagated to the caller. #634
Open
tbartley opened 3 years ago
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Failures to create subscriptions when using default aws-appsync-subscription-link are not propagated to the caller.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
What is the expected behavior?
At 3 above, error should be propagated to the caller so they know the subscription has failed.
Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?
aws-appsync + aws-appsync-subscription-link 4.0.3
Using this under nodejs (Node 12) to perform system testing.
Don't know if this has previously worked.
In my case the subscription is an Cognito user pool authorized subscription. Don't know if this makes a difference.
I suspect this is related to the call to __verifySubscriptionAlreadyStarted at https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/fc173bfe3ce262b1dba422021fc57097c4926b7b/packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts#L125 where the promise that it returns is dropped and not awaited.
I tried to fix this naively just by adding an
await
to this call. This helps - at least it makes the subscription fails. But the promise resolves rather than being rejected indicating that thesubscriptionReadyCallback
is getting called before/instead of thesubscriptionFailedCallback
and so the subscribe always fails at https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/fc173bfe3ce262b1dba422021fc57097c4926b7b/packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts#L132