[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)
SDK versions:
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
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 problematicexpo 52 will have text-decoder ootb but until then you just need a polyfill
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...
They’re using the canary from that PR
I was able to get it to not error out using a polyfill (
text-encoding-polyfill
). But then my uploads are failing with
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 appCan you get the error.cause when it fails with that error?
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)
Can you enable debug logs on the server side to see where it is getting hung up on more detail?