-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[React-Native] DynamoDB broken? #1614
Comments
@hassankhan I am seeing an issue, but not quite the same as you are. When I try to do a scan, I get a CRC32CheckFailed error. This occurs when the CRC32 checksum the SDK calculates on the response body is different than the value sent back by the service. When this issue is encountered, the SDK will automatically retry the request, up to 10 times (with exponential back-off between tries). With 10 retries, it is possible that the operation would take ~24 seconds to respond, are you sure that's not the case here? You can reduce the number of retries as well. I think the way the SDK is calculating the checksum for DynamoDB responses may be buggy in React Native, so I'll look into that. As a workaround, you can disable calculating the checksum on the SDK side. const awsConfig = new AWSSDK.Config({
accessKeyId : '',
secretAccessKey : '',
region : 'us-east-1',
maxRetries: 2, // reduce number of retries from 10 to 2
dynamoDbCrc32: false // disable SDK-side crc32 check
}); |
Thanks for the reply @chrisradek! I did also get a "dependencies": {
"aws-sdk": "^2.78.0",
"react": "^16.0.0-alpha.12",
"react-native": "^0.45.1"
}, As you mentioned, it may be possible that it takes a long time but if I override the global XmlHttpRequest I can see the responses returned fine. It's only when I disable it that it seems to not work at all. I'll give it another go with checksumming/retries disabled and report back. |
@hassankhan In browser environments that support CORS (most/all browsers), this header isn't accessible in the JavaScript runtime because the service doesn't explicitly expose it. For this reason, the CRC32 check isn't performed in browsers. In React Native, CORS is not enforced, so the JavaScript environment does have access to all headers, including There is one more gotcha. DynamoDB will gzip the response payload if its size exceeds some threshold (I'm not 100% sure what size that is). According to this comment, DynamoDB calculates the crc32 checksum after the payload is gzipped. By the time it reaches the JavaScript runtime, it is no longer gzipped so the CRC32 checksum the SDK calculates won't match. It's this behavior that causes some checksums to pass and some to fail, correlating to the size of the response body. We could try disabling gzip (assuming React Native's XMLHttpRequest implementation doesn't overwrite the Accept-Encoding header), but this will cause more data to be transferred over the wire. That might be useful to add as a configuration option for when payload sizes don't matter. In the meantime, disabling the CRC32 check should unblock you for now. |
Hi @chrisradek, sorry for the late response, disabling the CRC32 checks works for me 😄 |
Looks like @chrisradek explanation was suitable to get things working for React-Native. Closing out this issue. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Hi, we're trying to use DynamoDB from the React-Native SDK and experiencing rather unusual problems in that some requests work, others never seem to complete.
For example, calling
DynamoDB.listTables()
works as expected, and returns a response every time. However callingDynamoDB.getItem
never completes.We're also using Typescript, so I tried various combinations of
import/require
-ing the SDK with no change in behaviour.To enable request logging from the DevTools, we then added the following line:
Which unexpectedly started allowing the requests to start working, although intermittently (would fail 2/10 times). I tried using the code @chrisradek posted here
Component.tsx
The text was updated successfully, but these errors were encountered: