-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Expect: 100-continue HTTP protocol that s3 putObject uses does not work properly for bun #3766
Comments
Nodejs has specific handling for Sending an 'Expect' header will immediately send the request headers -- https://nodejs.org/dist/v5.2.0/docs/api/http.html#http_event_continue bun source does not contain '100-continue' and the area where I would expect it to be handled does not consider it: Line 2785 in b02f097
AWS SDK has some explicit middleware for ExpectContinue, if I comment this out the SDK works as expected. |
Same thing happening for me, any news on this? |
As a temporary workaround, uploading by pre-signed URLs can be used. import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
import options from '@options'
const getS3SignedUrl = async (bucked: string, key: string) => {
const client = new S3Client(options.s3configuration)
const command = new PutObjectCommand({
Key: key,
Bucket: bucked,
})
return getSignedUrl(client, command, { expiresIn: 600 })
}
export const uploadToS3 = async (buffer: Buffer, key: string) => {
const url = await getS3SignedUrl(options.s3configuration.bucket, key)
return fetch(url, {
method: 'PUT',
body: buffer,
})
} |
Thank you! 👍 I'll try it out once I'm back home on Friday :) |
What version of Bun is running?
0.7.0
What platform is your computer?
Darwin 21.4.0 arm64 arm
What steps can reproduce the bug?
Using the AWS s3-client, bun calls to putObject with a non-zero Body decode and expose "httpStatusCode: 100", whereas the same call in nodejs resolves "httpStatusCode: 200". This is a problem, because additional headers expose important funcitonality like the versionId of the object written, which is no longer accessible when using bun.
The problem is s3 returns two status codes in a row. See the example in AWS documentation https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html#API_PutObject_Example_1
Note this happens for non-version enabled buckets and also for real s3 servers (I repro on minio but it affects normal usage too).
repro.ts
To run the repro you need a s3 API running locally, here is a docker-compose for the backend
What is the expected behavior?
s3.putObject calls $metadata.httpStatusCode should return 200 and include VersionIid if availible.
What do you see instead?
s3.putObject calls $metadata.httpStatusCode return 100 and do not include VersionIid. This contrasts to node executing the same code which handles to 100 continue header properly.
Additional information
AWS is using the 100-continue protocol https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100 which seems not to work properly for bun
The text was updated successfully, but these errors were encountered: