uploadthing icon indicating copy to clipboard operation
uploadthing copied to clipboard

[bug]: Vercel production: FUNCTION_INVOCATION_FAILED on first attempt then succeeds on consecutive attemps

Open joshuaiz opened this issue 1 year ago โ€ข 5 comments

Provide environment information

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 73.42 MB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    pnpm: 7.18.2 - ~/Library/pnpm/pnpm
  Browsers:
    Brave Browser: 124.1.65.123
    Chrome: 109.0.5414.87
    Edge: 124.0.2478.80
    Safari: 17.4.1
    Safari Technology Preview: 17.4
  npmPackages:
    @uploadthing/react: ^6.5.1 => 6.5.1 
    uploadthing: ^6.10.1 => 6.10.1

Describe the bug

Uploading works locally without any issues.

On production (Vercel) I get the following errors in the console after selecting file(s) and clicking the 'Upload' button using the React Dropzone component.

My stack is Astro + React using the UploadThingSSR component.

UploadForm.CKwfOQ7V.js:24 
 POST https://towerlakes100.org/api/uploadthing?actionType=upload&slug=fileUploader 500 (Internal Server Error)

Something went wrong. Please contact UploadThing and provide the following cause: (FiberFailure) UploadThingError: Failed to report event "upload" to UploadThing server
    at https://towerlakes100.org/_astro/UploadForm.CKwfOQ7V.js:24:53641
    at https://towerlakes100.org/_astro/UploadForm.CKwfOQ7V.js:20:14869
overrideMethod @ console.js:273
(anonymous) @ UploadForm.CKwfOQ7V.js:24
await in (anonymous) (async)
n.current.n.current @ UploadForm.CKwfOQ7V.js:24

The upload fails. But then if I click the 'Upload' button again, it uploads the second time.

Link to reproduction

https://towerlakes100.org/

To reproduce

Visit: https://towerlakes100.org/

Fill out the form - you can use dummy info: for the Island question select Goose Egg Island otherwise you will get an error.

Once the form is filled out, we show the uploader. Select a file and attempt to upload by clicking the Upload button. The upload fails.

Click 'OK' on the alert failure message and then click the 'Upload' button again. It will work the second time (??)

Note: I have the window reload turned off after Upload Complete so the console messages can be viewed so on upload complete it will just show a success message but will not programmatically reload.

Additional information

Not sure why this is failing the first time but works the second time.

Here are the error logs from Vercel...there are two errors:

Error 1:

Unhandled Rejection: TypeError: fetch failed
at node:internal/deps/undici/undici:12345:11
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at runNextTicks (node:internal/process/task_queues:64:3)
at process.processImmediate (node:internal/timers:449:9)
at process.callbackTrampoline (node:internal/async_hooks:130:17) {
cause: ConnectTimeoutError: Connect Timeout Error
at onConnectTimeout (node:internal/deps/undici/undici:7492:28)
at node:internal/deps/undici/undici:7448:50
at Immediate._onImmediate (node:internal/deps/undici/undici:7480:13)
at process.processImmediate (node:internal/timers:478:21)
at process.callbackTrampoline (node:internal/async_hooks:130:17) {
code: 'UND_ERR_CONNECT_TIMEOUT'
}
}
Node.js process exited with exit status: 128. The logs above can help with debugging the issue.
Unknown application error occurred

Error 2 (Internal Server Error 500):

[POST] /api/uploadthing?actionType=upload&slug=fileUploader status=500

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

  • [ ] ๐Ÿ™‹โ€โ™‚๏ธ Yes, I'd be down to file a PR fixing this bug!

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

joshuaiz avatar May 05 '24 04:05 joshuaiz

The repo os here: https://github.com/joshuaiz/towerlakes100

joshuaiz avatar May 05 '24 15:05 joshuaiz

CleanShot 2024-05-06 at 15 13 23@2x

looking at the error from the network tab this doesn't look like an UploadThing error?

juliusmarminge avatar May 06 '24 13:05 juliusmarminge

@juliusmarminge yes that is a Vercel error but the endpoint is correct and it works the second time so it is a bit of a mystery.

joshuaiz avatar May 06 '24 13:05 joshuaiz

yea i just don't know how much i'll be able to help you. you're probably better off opening an issue over at astro or a support ticket to Vercel.

juliusmarminge avatar May 06 '24 14:05 juliusmarminge

No worries @juliusmarminge - thanks. Can confirm it works with isDev: true in the config. I will follow up with Vercel and in the Astro Discord and report back. Will leave this open for now.

joshuaiz avatar May 06 '24 19:05 joshuaiz

This issue has been automatically marked as stale because it has not had any activity for 10 days. It will be closed in 5 days if no further activity occurs.

github-actions[bot] avatar May 19 '24 00:05 github-actions[bot]

This issue has been closed because it has not had any activity for 5 days since being marked as stale.

github-actions[bot] avatar May 25 '24 00:05 github-actions[bot]