Is anyone using `"@aws-sdk/client-s3"` ?
Is anyone using
"@aws-sdk/client-s3"
?
I currently do:
Any my workers throws a 500 with: Cannot convert object to primitive value
38 Replies
I have a similar code for my pages function, and it is working fine.
Are you getting this error when running any operation?
Yes this is just at the beginning of my code, so before any op
I also double checked all env vars and they are logged correctly
You import it like this right:
import { S3Client } from "@aws-sdk/client-s3";
Yes. This is the GitHub repo for your reference: https://github.com/harshil1712/nextjs-r2-demo/blob/main/lib/r2.ts
GitHub
nextjs-r2-demo/lib/r2.ts at main · harshil1712/nextjs-r2-demo
Contribute to harshil1712/nextjs-r2-demo development by creating an account on GitHub.
Maybe I need
nodejs_compat
it's the only difference I see
Nope same error. So weird!
tried also by pinning v3.600Are all of your bindings strings?
That's my first guess, that for some reason, it is being given an object that it tries(and fails) to cast into a string
I don't use bindings
For
process.env
?Those are env variables
Set here
Hm... running it locally, does it throw the same error?
No locally it works perfectly
also, when I do:
I get the strings as expected, also in prod
Does the error show which exact line it is failing on?
Yes but it's minified so it's messed up. But I tried with console.log(1) and console.log(2) just before and after
new S3Client({
and log(2) doesn't show up
so it's somewhere in new S3Client()
Yeah, I'm trying to figure out whether it is failing on the endpoint, or the credentials
Let me try spinning a repro, and seeing if I can replicate your error
Wait, it is Nuxt...
Not Next
Ugh, rebuilding
nuxt deserves more love
such a nice tool
But yeah the whole app is bundled in there, so it's hard to reproduce
Can you disable minification?
on cl dashboard?
No, in Nuxt
I don't think, I'm googling it, but I think server code it's always minified
I've also added
toString()
but doesn't help:
I'm pretty sure creds are correct (also form the logs screenshotted)
from the logs, I think it happens here: export const defaultUserAgent = ({ serviceId, clientVersion }: DefaultUserAgentOptions): Provider<UserAgent> => {GitHub
aws-sdk-js-v3/packages/util-user-agent-node/src/index.ts at 72db2b5...
Modularized AWS SDK for JavaScript. Contribute to aws/aws-sdk-js-v3 development by creating an account on GitHub.
So some of this in workers is an object and not a string:
I just don't get why it happens to me and not everyone else
I'm getting the same
Yeah, so it isn't just a you issue...
yes but S3Client is fairly used in workers and I can't find a single mention of this
maybe is nuxt doing some polyfill to fix node
I'm guessing maybe it is a Nuxt + S3 issue
Let me see if I can get a bit closer
🙏
Found it!
OMG
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
Looking at the unminified code isn't very enlightening, but yeahAny solution?
Disable
unenv
somehow? Not entirely sure, probably something you want to flag either to the Nuxt or unenv
teamThanks a ton for the investigation
super helpful.
Sorry I couldn't do more there. Tbh, I don't do much(if anything) in Nuxt, so I might not be the best person for this kind of thing
It's great
I now know where to go
Thanks a ton