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

Appsync subscription timeout is not configureable #512

Open ghost opened 4 years ago

ghost commented 4 years ago

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

What is the current behavior? If a successful subscription has been established, and the computer loses internet connection, there is a 5 minute timeout before the appsync-sdk tries to reconnect. In those 5 minutes, subscription events are still recorded somewhere, and if internet connection is re-established, appsync-sdk will rapidly fire all missed subscription events.

This is our aws configuration:

export const appSyncClient = new AWSAppSyncClient({
        url: awsConfig.aws_appsync_graphqlEndpoint,
        region: awsConfig.aws_appsync_region,
        auth: {
            type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
            jwtToken: async () => (await auth.currentSession()).getIdToken().getJwtToken(),
        },
        disableOffline: true
    },
    {
        defaultOptions: {
            watchQuery: {
                fetchPolicy: 'network-only',
            },
        },
    }
);

As you can see, disableOffline is true and the fetchpolicy is network-only.

What is the expected behavior? We should either be able to reduce or remove the timeout before retries, or disable the appsync-sdk's ability to catch-up to subscription events after a brief internet loss, as this is undesirable in our system.

Is this currently possible with a workaround, or could this be implemented as a feature?

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions? Nodejs 12.14.0, windows 10 pro 1909, appsync-sdk 3.0.2. Previous versions have not been tried.

FatalTouch commented 4 years ago

+1 , using 'aws-appsync-subscription-link' with apollo client so even the catchup doesn't happen after 5 minutes. The timeout should be configurable.

pragupnewzera commented 4 years ago

+1 , using 'aws-appsync-subscription-link' with apollo client so even the catchup doesn't happen after 5 minutes. The timeout should be configurable.

@FatalTouch any update on this using aws-appsync-subscription-link?