Closed natuan62 closed 4 weeks ago
Hi @natuan62 this error is most likely caused by your local system time is out of sync. Please double check your local system date/time is correct and try again.
Thanks for your reply.
Hi @HuiSF But Any way to set correctClockSkew
like aws-sdk with amplify v6. ?
Many enduser has problem with time, we can't email to each end-user and instruction them set time, time-zone ... on mac-os or windows, ... mobile, etc.
I see same problem https://stackoverflow.com/questions/77937344/aws-amplify-v6-clock-sync-issue-after-upgrading-packages-and-manual-clock-change
But
The basic problem is that in core/src/clients/middleware/retry/defaultRetryDecider.ts#L19
const errorCode = parsedError?.code;
amply-js has MR fixed this
Thanks for the additional info @natuan62 I'll dig into it.
Hi @natuan62 I can confirm that Amplify JS v6 has built-in mechanism to auto-correct the clock skew via retying on the RequestTimeTooSkewed
error. This mechanism relying on reading the response.headers.Date
value.
With S3, the response.headers.Date
value is invisible to Amplify JS due to the default CORS policy, you need to update your S3 bucket CORS policy to enable it, and further to ensure the clock skew auto-correcting work as expected.
You can do so by:
Date
to ExposeHeaders
it looks like the following:[
{
"ID": "S3CORSRuleId1",
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET",
"HEAD",
"PUT",
"POST",
"DELETE"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": [
"x-amz-server-side-encryption",
"x-amz-request-id",
"ETag",
"Date"
],
"MaxAgeSeconds": 3000
}
]
Could you give it try? I think we need to update the documentation to call this out.
@HuiSF Thank you. I can confirm it works fine after Add Date to ExposeHeaders
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
Storage
Amplify Version
v6
Amplify Categories
storage
Backend
None
Environment information
Describe the bug
Expected behavior
Can upload file and return response successfully
Reproduction steps
Code Snippet