My upload button receives the presignedUrls from the server but when fetching the url it hangs.

Its odd because the image goes to upload thing and i can see it in my dashboard but the request on my client never recieves a response. Here is my upload button component:
<UploadButton
endpoint='imageUploader'
onUploadError={(error: Error) => {
toast.error('Upload Failed: ' + error.message);
}}
onClientUploadComplete={(res) => {
// this never fires
toast.success('Upload Successful');
}}
onBeforeUploadBegin={(files) => {
return files.map((f) => new File([f], uuid(), { type: f.type }));
}}
headers={{
...csrfHeaders,
}}
/>
<UploadButton
endpoint='imageUploader'
onUploadError={(error: Error) => {
toast.error('Upload Failed: ' + error.message);
}}
onClientUploadComplete={(res) => {
// this never fires
toast.success('Upload Successful');
}}
onBeforeUploadBegin={(files) => {
return files.map((f) => new File([f], uuid(), { type: f.type }));
}}
headers={{
...csrfHeaders,
}}
/>
export const uploadRouter = {
imageUploader: f({
image: {
maxFileSize: '4MB',
maxFileCount: 1,
},
})
.onUploadComplete(async (data) => {
// Never reaches
console.log('data', data);
})
} satisfies FileRouter;
export const uploadRouter = {
imageUploader: f({
image: {
maxFileSize: '4MB',
maxFileCount: 1,
},
})
.onUploadComplete(async (data) => {
// Never reaches
console.log('data', data);
})
} satisfies FileRouter;
No description
No description
No description
20 Replies
lonelyplanet
lonelyplanetOP3mo ago
This seems like a UploadThing backend issue?
lonelyplanet
lonelyplanetOP3mo ago
No description
lonelyplanet
lonelyplanetOP3mo ago
failed in 25.6minutes
julius
julius3mo ago
usually it's because you have some middleware blocking requests to your server. can you enable debug logs and try again
lonelyplanet
lonelyplanetOP3mo ago
I kept trying to fix it until i gave up striped out my current implementation and redid and it worked I dont know exactly what went wrong but I believe it was the middleware
JoelRB
JoelRB2mo ago
Hi, were you able to fix this? I am getting this issue now on a live server. Local dev works but not in production server. It worked before in v6. //not getting here also onClientUploadComplete={(res) => { console.log("UPLOAD DONE! ", res); Hi @julius can you clarify this? I didn't have this problem in v6. Aside from upgrading to v7, the only other change is moving the Nextjs app out of Azure container as it's too slow to an Azure Ubuntu VM. What could possibly block it? The file is actually uploaded to UploadThing.
julius
julius2mo ago
global middleware, some reverse proxy maybe. the callback should be treated like a webhook. it doesn't come from an authenticated user (unlike the request that hits the .middleware() function) so you cannot put /api/uploadthing behind auth
JoelRB
JoelRB2mo ago
Ok thanks, I'll check again.
JoelRB
JoelRB2mo ago
Hi @julius please bear with this. I still can't find any solution. I noticed in the browser for the live website it displays a "pending" on xhr. Is that the one being "blocked?"
No description
JoelRB
JoelRB2mo ago
In my local dev, the xhr points to uploadthing client index.js.
No description
julius
julius2mo ago
Yes it’s blocking until your server has acknowledged the upload complete (I.e your server’s onUploadComplete has finished) - can you see any network request (POST /api/uploadthing) coming into your prod server? In total there should be 2, one from the client when they request the upload and you generate the signed url, and then one from the uploadthing server after the upload has finished that will trigger onUploadComoletr callback
julius
julius2mo ago
No description
JoelRB
JoelRB2mo ago
I have this post /api/uploadthing?actionType=upload&slug=docAnalyzeFileUpload ... also the presigned https://sea1.ingest.uploadthing.com/xEVowJainSDGSKXuCJI8R7KOIQwAMjmzxcP9no5ET2LUVFpg?expires=1731497365430&x-ut-identifier=xmurrfld3n&x-ut-file-name=user_2lL1jFWlzieExut2Gep6KQySdA7-350KB.pdf&x-ut-file-size=359075&x-ut-file-type=application%252Fpdf&x-ut-slug=docAnalyzeFileUpload&x-ut-content-disposition=inline&signature=hmac-sha256%3D9db1ea5f92fa933cc330bb1fcb969bdc8a5570dba23fba45b2bb2c277b6c2ce3 I don't have the onUploadComplete. It doesn't get to that. I put a log on so and it's not registering in the browser. .onUploadComplete(async ({ metadata }) => {
log.debug("Upload Complete Metadata: ", metadata); console.log("Upload Complete Metadata: ", metadata); return { uploadedBy: metadata.userId };
JoelRB
JoelRB2mo ago
I local dev, I can see that
No description
JoelRB
JoelRB2mo ago
I meant that's the log in the dropzone on uploade complete. The other log is in the core.ts:
No description
JoelRB
JoelRB2mo ago
@julius so I don't see coming into the server.
julius
julius2mo ago
Yea I was thinking if you could see it entering your network at all, and that way could tell if it was blocked somewhere on the way to the uploadthing handler (eg by a reverse proxy or somthing) Next thing you can do is enable debug logs and inspecting the request body of the request going to REGION.ingest.uploadthing.com/route-metadata - see what callbackUrl it’s sending and verifying that that url is matching your server. Sometimes the auto-detection isn’t 100% accurate if the right headers aren’t present
JoelRB
JoelRB2mo ago
Ok I will do that. Hopefully I can find a solution soon.
julius
julius2mo ago
Sorry that I can’t be more helpful. Not at home so can’t check our logs
JoelRB
JoelRB2mo ago
It's fine. You've been helpful. Thanks.
Want results from more Discord servers?
Add your server