awslabs / aws-mobile-appsync-sdk-js

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

Fix: Avoid error from null value for observer in timeoutStartSubscriptionAck function #595

Closed KvNGCzA closed 3 years ago

KvNGCzA commented 3 years ago

Issue #, if available:

515 #544 #596

Description of changes: An if statement to make sure that the observer exists before it tries to call the properties of observer in timeoutStartSubscriptionAck function

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

99darwin commented 3 years ago

Please pull this in!

ankur014 commented 3 years ago

There have been multiple issues opened related to this, can we get this merged, please?

loganbertrand commented 3 years ago

Can we please merge this?

randomslap commented 3 years ago

Can this pull request get merged please? Subscriptions are unstable and it causes app to crash due to this issue.

jcbdev commented 3 years ago

This issue also exists in the timeoutDIsconnect function too!

AppSyncRealTimeSubscriptionHandshakeLink.prototype._timeoutDisconnect = function () {
        this.subscriptionObserverMap.forEach(function (_a) {
            var observer = _a.observer;
            observer.error({
                errors: [__assign({}, new graphql_1.GraphQLError("Timeout disconnect"))]
            });
            observer.complete();
        });
        this.subscriptionObserverMap = new Map();
        if (this.awsRealTimeSocket) {
            this.awsRealTimeSocket.close();
        }
        this.socketStatus = types_1.SOCKET_STATUS.CLOSED;
    };

Would be good if we could cover both issues?

ankur014 commented 3 years ago

There hasn't been any traction on this for some time, so, we tried this workaround and it seems to be working. Adding it here so that others can give it a shot as well - https://dev.to/willsamu/how-to-get-aws-appsync-running-with-offline-support-and-react-hooks-678

KvNGCzA commented 3 years ago

Hey @jcbdev . I opened this to fix the issue in the timeoutDisconnect function. Thanks for the suggestion.

@sammartinez @elorzafe Hey guys. This PR has been open for a while, can we please get it merged?

99darwin commented 3 years ago

@elorzafe are you still monitoring this? the best Holiday gift you could give us all would be merging this PR! 🎄🎅

aehmt commented 3 years ago

@elorzafe are you still monitoring this? the best Holiday gift you could give us all would be merging this PR! 🎄🎅

What's the hold up with this? Can someone from AWS explain?

KvNGCzA commented 3 years ago

@sammartinez Hi, have I missed a step in opening this PR? I read and followed the contributing guidelines. Maybe I missed something. Kindly give feedback on the next steps.

KvNGCzA commented 3 years ago

@elorzafe Thank you for your response. Cheers.