awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
921 stars 266 forks source link

Subscription timeout issues (Uncaught inpromise and TypeError: Cannot read property 'error' of null) #594

Open accel9 opened 4 years ago

accel9 commented 4 years ago

Note: If your issue/feature-request/question is regarding the AWS AppSync service, please log it in the official AWS AppSync forum

Do you want to request a feature or report a bug? I want to report a bug

What is the current behavior? I keep getting UnhandledRejection in sentry with an error message "Non-Error promise rejection captured with keys: errorCode, errorMessage" with additional data {"errorCode":1,"invocationContext":"[undefined]","errorMessage":"AMQJSC0001E Connect timed out."}.

I believe this is the issue when handshake is not successful in 30 seconds and the request gets timeout, I think we cannot configure the timeout for subscription and I don't find any information to handle this error.

I am attaching the full code for reference and screenshots of errors. I believe there might be some way to catch rejected promise in the subscription (Subscription code attached in file) so Can you please help me how can I do that and share docs which explain the same.

Code Reference: Code_reference.txt

Screenshots of error: Screenshot (730) Screenshot (731) Screenshot (732)

I also tried upgrading aws-appsync to version v4.0.1 but it too have issues with timeout. I am getting this error "TypeError: Cannot read property 'error' of null". Same issue is posted here https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/544 but it's still not resolved yet.

Screenshots of error in v4.0.1: Screenshot (815) Screenshot (816)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

This error is replicated when the handshake was not successful and gets timeout after 30 seconds.

What is the expected behavior? There should be a way to catch uncaught promises in v1.8.1 or in v4.0.1 is there any way to handle this error TypeError: Cannot read property 'error' of null

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions? I am using React v16.12.0, react-apollo v2.5.8 and aws-appsync v1.8.1 for real time update using subscription. I have also tried upgrading aws-appsync to 4.0.1 but am getting this error https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/544