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

Offline complex object mutations cause React Native Apps to crash #560

Open matthiaszyx opened 4 years ago

matthiaszyx commented 4 years ago

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

What is the current behavior? In React Native, using the AWSAppSyncClient to upload a complex object (i.e. a file) to S3 causes the App to freeze and/or crash if the file is at least a few megabytes in size and the offline capability of the AWSAppSyncClient is not disabled (i.e. disableOffline is set to false). (Note: if the file is very small or if the offline feature of the AWSAppSyncClient is disabled uploading files does work).

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Upload a file using the AWSAppSyncClient like this:

const fileBuffer = new Buffer(await RNFetchBlob.fs.readFile(file.uri, "base64"), "base64");
client.mutate({
    mutation: gql(`
        mutation createItem($file:S3ObjectInput!) {
            createItem(file: $file) { id file { bucket region key } }
        }
    `,
    variables: {
        file: {
            bucket: 'mybucket',
            region: 'eu-central-1',
            key: 'mykey',
            mimeType: file.type,
            localUri: fileBuffer
        }
    }
});

What is the expected behavior? No crashes or freezes.

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions? Environment: react-native, Versions: any that I have tried, for example the current ones: react-native@0.62.2, aws-appsync@3.0.3