-
Notifications
You must be signed in to change notification settings - Fork 593
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
S3.headBucket doesn't throw NotFound error when bucket doesn't exist #1340
Comments
Okay so interesting findings. I think this may no longer be a GA blocker, but is still an issue pending investigation. Region is defaulted to us-west-2
I received a 200 response back
Then I set the region to
Then I set the region back to |
Okay so this looks like a caching issue with s3. Not a GA blocker. It looks like the cache gets invalidated on the global endpoint first (us-east-1) and then becomes eventually consistent elsewhere. To make this work immediately force your request to go to us-east-1 |
Verified that the HTTPResponse remains the same in v3 after bucket deletion is successful.
Codeconst AWS = require("aws-sdk");
const { S3 } = require("@aws-sdk/client-s3");
(async () => {
let response;
const region = "us-west-2";
const Bucket = `test-bucket-${Math.ceil(Math.random() * 10 ** 10)}`;
const logger = { debug: console.log };
const v2Client = new AWS.S3({ region });
const v3Client = new S3({ region, logger });
await v2Client.createBucket({ Bucket }).promise();
await v2Client.waitFor("bucketExists", { Bucket }).promise();
response = await v3Client.headBucket({ Bucket });
// console.log(`v3 headBucket: ${JSON.stringify(response, null, 2)}`);
await v2Client.deleteBucket({ Bucket }).promise();
await v2Client.waitFor("bucketNotExists", { Bucket }).promise();
// try {
// response = await v2Client.headBucket({ Bucket }).promise();
// console.log(`v2 headBucket: ${JSON.stringify(response, null, 2)}`);
// } catch (e) {
// console.log(`v2 Error:`);
// console.log(e);
// }
try {
response = await v3Client.headBucket({ Bucket });
// console.log(`v3 headBucket: ${JSON.stringify(response, null, 2)}`);
} catch (e) {
// console.log(`v3 Error:`);
// console.log(e);
}
})(); Output{
httpRequest: HttpRequest {
method: 'HEAD',
hostname: 's3.us-west-2.amazonaws.com',
port: undefined,
query: {},
headers: { 'Content-Type': '' },
body: undefined,
protocol: 'https:',
path: '/test-bucket-7155967407'
}
}
{
httpResponse: HttpResponse {
statusCode: 200,
headers: {
'x-amz-id-2': 'RsILGp4U4QkPhV9WQ+Ao/FcRkjvCiMnywqtaqYVWASWF+qcEk26Uj/KHPk4X2PbBTDPrHPQ4/2c=',
'x-amz-request-id': '06562013940ED2EA',
date: 'Thu, 29 Oct 2020 21:09:11 GMT',
'x-amz-bucket-region': 'us-west-2',
'content-type': 'application/xml',
'transfer-encoding': 'chunked',
server: 'AmazonS3'
},
body: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
socket: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 200,
statusMessage: 'OK',
client: [TLSSocket],
_consuming: false,
_dumped: false,
req: [ClientRequest],
[Symbol(kCapture)]: false,
[Symbol(RequestTimeout)]: undefined
}
}
}
{
httpRequest: HttpRequest {
method: 'HEAD',
hostname: 's3.us-west-2.amazonaws.com',
port: undefined,
query: {},
headers: { 'Content-Type': '' },
body: undefined,
protocol: 'https:',
path: '/test-bucket-7155967407'
}
}
{
httpResponse: HttpResponse {
statusCode: 200,
headers: {
'x-amz-id-2': 'DT+GGRYtW4ylOxfPxXaQiZTjCJQuqWiNpsXemLm/8v9xTY/MUyabZeQcAE9fTb1KRHP4xmPSdnA=',
'x-amz-request-id': 'E6465A2789D60155',
date: 'Thu, 29 Oct 2020 21:09:12 GMT',
'x-amz-bucket-region': 'us-west-2',
'content-type': 'application/xml',
'transfer-encoding': 'chunked',
server: 'AmazonS3'
},
body: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
socket: [TLSSocket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
aborted: false,
upgrade: false,
url: '',
method: null,
statusCode: 200,
statusMessage: 'OK',
client: [TLSSocket],
_consuming: false,
_dumped: false,
req: [ClientRequest],
[Symbol(kCapture)]: false,
[Symbol(RequestTimeout)]: undefined
}
}
} |
The global s3 client proposal will have fix this issue: #1807. Change this to documentation as we need to provide more detailed explanation of what happens under the hood. |
Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new 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. |
Describe the bug
S3.headBucket doesn't throw NotFound error when bucket doesn't exist
SDK version number
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
To Reproduce (observed behavior)
Code
Details
Expected behavior
S3.headBucket should throw error when bucket doesn't exist
The text was updated successfully, but these errors were encountered: