Fetch Request Returns 'Undefined' during File Upload Polling Process"

I am experiencing an issue with my Cloudflare Worker that is part of a file upload process using the UploadThing library. The worker is responsible for polling the upload status from an external server (https://uploadthing.com/api/pollUpload/...). However, I'm encountering a problem where the polling doesn't happen and the fetch request within the worker therefore does not return a response, resulting in an 'undefined' value. Below is a summary of the process and where the issue occurs: 1. A POST request is initiated to http://localhost:3000/api/uploadthing?actionType=upload&slug=videoAndImage. 2. This triggers the buildRequestHandler function within UploadThing, which parses the request and forwards it to https://uploadthing.com/api/prepareUpload. 3. Upon receiving a successful response from UploadThing, the conditionalDevServer function called in buildRequestHandler initiates a polling process using pollForFileData. 4. pollForFileData, wrapped with withExponentialBackoff, makes a fetch request to https://uploadthing.com/api/pollUpload/... to check the upload status. 5. The fetch request is configured with the necessary headers, including an API key and SDK version. 6. However, the polling doesn't happen, and the fetch request does not return any response, resulting in 'undefined'. I have attached a video demonstrating the issue, where I step through the execution using a debugger. Additionally, here is the link to a pull request (PR) that is currently being worked on in the UploadThing repository: https://github.com/pingdotgg/uploadthing/pull/514/commits This PR contains relevant code changes that might provide further insights into the issue. I am looking for insights into why the polling doesn't return a response. Any suggestions on troubleshooting steps, potential causes, or configuration changes that could resolve this issue would be greatly appreciated. Thank you in advance for your help
1 Reply
kristiankauffeld
kristiankauffeldOP12mo ago
Here is a screenshot of the browser console logs which shows that since the polling doesn't return a response and it attempts to receive a respone a maximum number of 21 times. At the end the upload process actually completes. The retry mechanism is defined here: https://github.com/pingdotgg/uploadthing/blob/60d3ccfbe312775fd1c2156fcc362862eac843cb/packages/shared/src/utils.ts#L136-L161
Want results from more Discord servers?
Add your server