pingdotgg / uploadthing

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

fix: gracefully handle download errors #1058

Closed juliusmarminge closed 5 days ago

juliusmarminge commented 6 days ago

ref: https://discord.com/channels/966627436387266600/1307658378968961138

Summary by CodeRabbit

Release Notes

vercel[bot] commented 6 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-uploadthing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 8:51am
1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **legacy-docs-uploadthing** | ⬜️ Ignored ([Inspect](https://vercel.com/pinglabs/legacy-docs-uploadthing/DeuNgDgEf8VARxRuZqsFRDo6kkQP)) | [Visit Preview](https://legacy-docs-uploadthing-git-handle-download-errors-pinglabs.vercel.app) | | Nov 19, 2024 8:51am |
changeset-bot[bot] commented 6 days ago

🦋 Changeset detected

Latest commit: aaf79efef103b1f7089f2942609205d79d64f67a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------- | ----- | | uploadthing | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

coderabbitai[bot] commented 6 days ago

Walkthrough

The changes introduce improvements to error handling in the utapi.uploadFilesFromUrl function, allowing it to manage download errors more effectively during file uploads. The UTApi class in packages/uploadthing/src/sdk/index.ts has been updated for enhanced clarity and robustness in error reporting. The restructuring of functions in packages/uploadthing/src/sdk/utils.ts includes the introduction of new methods for downloading files and generating presigned URLs, while the test suite in packages/uploadthing/test/sdk.test.ts has been enhanced to ensure proper handling of download errors.

Changes

File Path Change Summary
.changeset/modern-numbers-cough.md Updated utapi.uploadFilesFromUrl to include error handling for download errors.
packages/uploadthing/src/sdk/index.ts Modified UTApi class; refactored uploadFiles and uploadFilesFromUrl methods for better error handling and clarity. Updated import statements and method signatures.
packages/uploadthing/src/sdk/utils.ts Removed uploadFilesInternal and downloadFiles functions; added downloadFile and generatePresignedUrl functions with improved error handling.
packages/uploadthing/test/sdk.test.ts Enhanced test suite for uploadFiles and uploadFilesFromUrl methods; added tests for handling download errors.

Possibly related PRs

Suggested labels

examples

Suggested reviewers

Poem

🐇 In the meadow, files do play,
With URLs that lead the way.
Errors caught, no need to fret,
Uploads now, a safe duet!
A hop, a skip, all's well in sight,
Thanks to code, our files take flight! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
pkg-pr-new[bot] commented 6 days ago

Open in Stackblitz

More templates

- [@example/minimal-appdir](https://pkg.pr.new/template/b6986951-679c-4737-abcf-560b997457bb) - [@example/minimal-astro-react](https://pkg.pr.new/template/08a9a1c1-322e-4984-9b51-7fda003197b7) - [@example/minimal-nuxt](https://pkg.pr.new/template/f78a38e9-bbbb-4660-8c7a-49328bdf5f46) - [@example/minimal-expo](https://pkg.pr.new/template/596b2c80-d476-4aca-abff-436b5fbcba64) - [@example/minimal-pagedir](https://pkg.pr.new/template/347b411a-5827-4a7a-838d-117368f64f7d) - [@example/minimal-solidstart](https://pkg.pr.new/template/3cc2d867-a059-482b-b679-e83532e03914) - [@example/minimal-sveltekit](https://pkg.pr.new/template/ff914c71-aa0b-4a39-9404-5e71b86ebeac) - [@example/minimal-tanstack-start](https://pkg.pr.new/template/48a64757-1072-4b5e-a116-ae637e3047da)

pnpm add https://pkg.pr.new/pingdotgg/uploadthing@1058

commit: aaf79ef

github-actions[bot] commented 6 days ago

📦 Bundle size comparison

Bundle Size (gzip) Visualization
Main 27.59KB No treemap on forks
PR (110f4c68582e63d9e6d465fb66a39a3afa05c959) 27.59KB No treemap on forks
Diff No change