unjs / unenv

🕊️ Convert javaScript code to be runtime agnostic
MIT License
340 stars 18 forks source link

OS proxy doesn't work #279

Open cosbgn opened 2 days ago

cosbgn commented 2 days ago

Environment

cloudflare workers

Reproduction

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

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

Describe the bug

If you try to initialize the S3 sdk in cloudflare workers it fails with Cannot convert object to primitive value.

After investigating with the r2 team we reached this conclusion:

It appears that Nuxt is using unenv to smooth over differences in runtimes
And one of the things it does on build is replace imports from os with a proxy that doesn't appear to be working correctly

Additional context

S3 expects varables to be string, unenv is not passing them as string

Logs

No response

cosbgn commented 2 days ago

Reproduction:

https://github.com/cosbgn/s3-bug-nitro https://s3-bug-nitro.pages.dev