Skip to content

fix: upload handler issue related to new react-router api#2194

Merged
DonKoko merged 2 commits intomainfrom
fix-image-upload-issue
Nov 24, 2025
Merged

fix: upload handler issue related to new react-router api#2194
DonKoko merged 2 commits intomainfrom
fix-image-upload-issue

Conversation

@DonKoko
Copy link
Copy Markdown
Contributor

@DonKoko DonKoko commented Nov 24, 2025

No description provided.

@vercel
Copy link
Copy Markdown

vercel bot commented Nov 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
shelf-docs Ignored Ignored Nov 24, 2025 3:49pm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an upload handler issue related to changes in the React Router API's file upload handling. The new React Router version (via @remix-run/form-data-parser) changed the structure of the upload handler parameter, which previously provided destructured file, type, and name properties, but now provides a different object shape that needs to be normalized.

Key changes:

  • Added import for Node.js Readable stream to handle stream conversions
  • Refactored parseFileFormData upload handler to handle multiple possible API shapes from the form parser
  • Added normalizeToAsyncIterable function to convert various file formats (Blob, Buffer, Readable streams, async iterables) into a consistent AsyncIterable format that Sharp can process
  • Refactored anonymous generator function in uploadImageFromUrl to a named function for consistency

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
package-lock.json Routine dependency updates including Vue, lodash types, msw, and various other packages
app/utils/storage.server.ts Fixed upload handler to support new React Router API by normalizing file upload parameter shapes and converting to AsyncIterable format
Comments suppressed due to low confidence (1)

app/utils/storage.server.ts:272

  • Corrected spelling of 'Supoabase' to 'Supabase'.
 * Logs an error that occurred during image upload to Supoabase

Comment on lines +292 to +301
async function normalizeToAsyncIterable(
file:
| AsyncIterable<Uint8Array>
| Readable
| Buffer
| Blob
| { stream?: () => any; arrayBuffer?: () => Promise<ArrayBuffer> }
| null
| undefined
): Promise<AsyncIterable<Uint8Array> | null> {
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function parameter type includes { stream?: () => any; arrayBuffer?: () => Promise<ArrayBuffer> } but the JSDoc comment only mentions Blob, File, Buffer, Node streams, and async iterables. Consider updating the JSDoc to explicitly mention this object shape or clarifying what it represents (likely the undici File polyfill mentioned in line 321).

Copilot uses AI. Check for mistakes.
@DonKoko DonKoko merged commit 282ade5 into main Nov 24, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants