[Expo + UT] Error when importing @uploadthing/expo

Hey, I am building an expo app and I am getting this error when importing the package (only on native, web works fine)
Property 'TextDecoder' doesn't exist
Property 'TextDecoder' doesn't exist
SDK versions:
"@uploadthing/expo": "7.0.4-canary.8bc74c6",
"uploadthing": "7.1.1-canary.8bc74c6",
"@uploadthing/expo": "7.0.4-canary.8bc74c6",
"uploadthing": "7.1.1-canary.8bc74c6",
Attaching my stacktrace from sentry (raw and a screenshot). I looked at the SDK source and found that the only place where TextDecoder is used is packages/uploadthing/src/internal/shared-schemas.ts Help appreciated 🙂
8 Replies
markr
markr•8h ago
I think RN doesn’t have TextDecoder natively, you need to polyfill it eg expo install @bacons/text-decoder Cc @julius - RN + effect might be somewhat problematic
julius
julius•8h ago
expo 52 will have text-decoder ootb but until then you just need a polyfill
julius
julius•8h ago
there is an issue though which i've half fixed here: https://github.com/pingdotgg/uploadthing/pull/1013 but still not entiery fixed. my guess it's RNs weird blob implementation
GitHub
fix: @uploadthing/mime-types exports not supported in Expo by jul...
Closes #999 flatten export paths since Expo doesn't resolve exports condition by default. This is similar to what we do for the main uploadthing package which has multiple entrypoints as w...
markr
markr•8h ago
They’re using the canary from that PR
sudhanshug
sudhanshugOP•8h ago
I was able to get it to not error out using a polyfill (text-encoding-polyfill). But then my uploads are failing with
[(MicroCause.Fail) UploadThingError: Failed to report event "upload" to UploadThing server]
[(MicroCause.Fail) UploadThingError: Failed to report event "upload" to UploadThing server]
This error may or may not be related The SDK does not even call my /api/uploadthing endpoint. However, the same setup works fine on the web export of the app
markr
markr•8h ago
Can you get the error.cause when it fails with that error?
sudhanshug
sudhanshugOP•7h ago
That was a false alarm, I did not setup port forwarding correctly on my device - the host wasn't found hence no requests. But now I am getting the error "UPLOAD_FAILED" (code and message is the same) with undefined err.cause. The upload action to my /api/uploadthing API resolves to a 200 response so I am assuming it is failing to upload to the signed URL. (trying to confirm this assumption)
markr
markr•4h ago
Can you enable debug logs on the server side to see where it is getting hung up on more detail?
Want results from more Discord servers?
Add your server