pingdotgg / uploadthing

File uploads for modern web devs
https://uploadthing.com
MIT License
4.27k stars 319 forks source link

[bug]: Expo broken on v7 #999

Closed juliesaia-vendora closed 3 weeks ago

juliesaia-vendora commented 1 month ago

Provide environment information

System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 86.67 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.2.0 - ~/.nvm/versions/node/v22.2.0/bin/node
    Yarn: 1.22.22 - ~/.yarn/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v22.2.0/bin/npm
    pnpm: 9.12.1 - ~/.nvm/versions/node/v22.2.0/bin/pnpm
    bun: 1.1.9 - ~/.bun/bin/bun
  Browsers:
    Chrome: 129.0.6668.90
    Safari: 17.6
  npmPackages:
    typescript: ^5.5.2 => 5.6.2 
    uploadthing: 7.0.2 => 7.0.2

Describe the bug

Expo seems to be broken on v7. When running examples/minimal-expo:

Unable to resolve "@uploadthing/mime-types/audio" from "node_modules/@uploadthing/shared/dist/index.cjs"

Easy fix is to replace require(@uploadthing/mime-types/[package]) with require(@uploadthing/mime-types/dist/[package]), but actually uploading a file gives:

Error: XHR failed 400 undefined - {"error": "No file on request"}

Link to reproduction

https://stackblitz.com/github/pingdotgg/uploadthing/tree/main/examples/minimal-expo

To reproduce

bun install

bun ios

After patching above, upload a file

Additional information

No response

๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ Contributing

Code of Conduct

juliusmarminge commented 1 month ago

I'll investigate this tomorrow. Currently installing xcode ios simulator and it's been downloading for hours now...

juliusmarminge commented 1 month ago

Hey,

Sorry for not getting back. This slipped my mind but was able to take a look today.

https://github.com/pingdotgg/uploadthing/blob/07d3f48eb2a6abc741167dc41bfaa1a21a96ae7c/packages/uploadthing/src/internal/upload.browser.ts#L59-L61

which is not gonna work since React Native doesn't have blobs. This has previously been fine since we've worked around it like this:

https://github.com/pingdotgg/uploadthing/blob/07d3f48eb2a6abc741167dc41bfaa1a21a96ae7c/packages/expo/src/image-picker.ts#L105-L119

More info in the linked React Native issue from that comment...

Will tihnk on how to solve this

juliusmarminge commented 1 month ago

update: doesn't seem relatved to that but on our fastify backend not recognizing the RN blob format... continuing investigating nvm that is the culprit

juliusmarminge commented 1 month ago

okay linked PR seems to fix it - releasing some canary versions that you can use until it gets released on main

juliesaia-vendora commented 1 month ago

tysm for looking into it :)

just tried canary on minimal-ut-expo, seems like the upload is going through but the file is blank with no size afterward, not sure if im doing something wrong

image

juliusmarminge commented 1 month ago

what's the file key?

juliesaia-vendora commented 1 month ago

AtUXM04uzR1mkV6hTW9zLSAGlcaXVCkutpo5rTZ8JnFbgjHR

I'm trying a default image from my ios simulator

juliusmarminge commented 1 month ago

hmm i can repro this on deployed infra. wonder why it worked locally then...

garshythoel commented 4 weeks ago

@juliusmarminge

I'm running into the same issue - a fix here would be a lifesaver