aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.12k stars 578 forks source link

Cannot convert object to primitive value #6248

Closed cosbgn closed 4 months ago

cosbgn commented 4 months ago

Checkboxes for prior research

Describe the bug

Can't initialize the SDK in cloudflare workers. Locally it works.

SDK version number

"@aws-sdk/client-s3": "^3.608.0"

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

cloudflare workers

Reproduction Steps

import { S3Client } from "@aws-sdk/client-s3";

const s3Client = new S3Client({
        region: "auto",
        endpoint: `https://${process.env.CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com`,
        credentials: {
            accessKeyId: process.env.CLOUDFLARE_R2_BUCKET_ACCESS_KEY_ID,
            secretAccessKey: process.env.CLOUDFLARE_R2_BUCKET_SECRET_KEY_ID,
        },
})

This fails with: Cannot convert object to primitive value.

Observed Behavior

This works on localhost but fails when deployed (cloudflare workers)

Expected Behavior

it works

Possible Solution

No response

Additional Information/Context

No response

aBurmeseDev commented 4 months ago

Hi @cosbgn - thanks for reaching out.

Can you share the full error and your SDK that would give us some insight into this behavior? Based on the report, my guess on the culprit is the endpoint value.

Since you mentioned this works on localhost and fails when deployed with Cloudflare workers, please note AWS does not guarantee support for 3rd party offerings like Cloudflare Workers. AWS supports Lambda as a serverless offering.

rahulkumarsingh73690 commented 4 months ago

@cosbgn You got any solution?

cosbgn commented 4 months ago

Yes, the issue is caused by unenv here I made a small reproduction: https://github.com/unjs/unenv/issues/279 I guess this falls out of scope for S3 so I'll close this issue and leave the one on unenv open

pi0 commented 3 months ago

Update: https://github.com/unjs/unenv/issues/279#issuecomment-2231505068

github-actions[bot] commented 3 months ago

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.