pingdotgg / uploadthing

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

[bug]: Svelte createUploader -> onClientUploadComplete broken in production. Package is unusable clientside. (@uploadthing/svelte 7.0.3) #1020

Closed Pascaltib closed 1 month ago

Pascaltib commented 1 month ago

Provide environment information

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1
    Memory: 106.84 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.5.0 - ~/.nvm/versions/node/v21.5.0/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v21.5.0/bin/npm
  Browsers:
    Chrome: 129.0.6668.101
    Safari: 18.0.1
  npmPackages:
    @uploadthing/svelte: ^7.0.3 => 7.0.3
    typescript: ^5.6.3 => 5.6.3
    uploadthing: ^7.1.0 => 7.1.0

Describe the bug

Uploading from the client is broken for Svelte in production.

I correctly receive the webhook, the file is stored in uploadthing but the client does not get a confirmation that the uploading process is done.

Video showing this

Link to reproduction

https://www.loom.com/share/c017d0954d6a40d08f0c863fa378962f?sid=279d464a-905b-4021-b399-e8bf7899c392

To reproduce

src/lib/utils/uploadthing.ts

import` type { OurFileRouter } from "$lib/server/uploadthing";
import { generateSvelteHelpers } from "@uploadthing/svelte";
export const { createUploader, createUploadThing } =
  generateSvelteHelpers<OurFileRouter>();
import { createUploader } from '$lib/utils/uploadthing'
const uploader = createUploader('fileUploader', {
    onClientUploadComplete: (res) => {
        console.log('Uploadthing Complete', res)
    }})
    ...
<UploadDropzone {uploader} />

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

Code of Conduct

Pascaltib commented 1 month ago

Temporary solution for this is to add { awaitServerData: false } to endpoint.

Currently there are no errors in onUploadComplete (when I run it in dev or prod).

juliusmarminge commented 1 month ago

can you still repro this? there were a few minutes on Wednesday where a missing edge case could cause infinite client loading

Pascaltib commented 1 month ago

I can confirm I can no longer repro this. Testing it with the exact same code. Hmmm it was definitely more than a couple of minutes I experienced this issue for more than half a day so maybe it was related to something else.

But glad that it's resolved!