Skip to content

fix: implement uploadBytes for storage modular sdk#9006

Open
mikehardy wants to merge 3 commits intomainfrom
@mikehardy/storage-upload-bytes
Open

fix: implement uploadBytes for storage modular sdk#9006
mikehardy wants to merge 3 commits intomainfrom
@mikehardy/storage-upload-bytes

Conversation

@mikehardy
Copy link
Copy Markdown
Collaborator

Description

This PR is fundamentally based on the excellent work from @johnsimeroth here (with CLA signed):

That PR was based on the main branch of his fork and I thought it would be very presumptious to force push to it, so I've opened a new PR off a personal branch here

Related issues

Release Summary

2 "fix" conventional commits, and the first one has the attribution for John correctly preserved

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

e2e test and type test, works locally


Think react-native-firebase is great? Please consider supporting the project with any of the below:

@mikehardy mikehardy requested a review from russellwheatley May 1, 2026 22:25
@mikehardy mikehardy added the Workflow: Needs Review Pending feedback or review from a maintainer. label May 1, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the uploadBytes API to the modular Firebase Storage SDK, addressing a missing piece of functionality. The implementation leverages the existing uploadBytesResumable method, ensuring robust handling of upload states and errors while maintaining type safety through a TypeScript port. This change significantly improves the developer experience by providing a complete and type-safe uploadBytes method, backed by comprehensive testing to verify its behavior and type definitions.

Highlights

  • Modular SDK Implementation: Implemented the uploadBytes function for the modular Firebase Storage SDK, providing a non-resumable upload mechanism.
  • TypeScript Migration and Type Safety: The implementation was ported to TypeScript, ensuring strong typing and consistency with other modular APIs, and UploadResult is now correctly used instead of TaskResult.
  • Enhanced Error Handling: Improved the error handling logic within uploadBytes to gracefully manage task states, including pauses, cancellations, and general errors.
  • Comprehensive Testing: New end-to-end (e2e) and type tests were added to thoroughly validate the functionality and type correctness of the uploadBytes method.
  • Type Consistency: Removed a specific type comparison exclusion for uploadBytes in the configuration, indicating that type definitions are now consistent.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements the uploadBytes function for the modular storage API, which was previously not implemented. It also adds corresponding E2E and type tests. The implementation wraps uploadBytesResumable in a Promise to provide the non-resumable behavior. Feedback identifies several issues in the implementation: a potential memory leak due to missing unsubscription from the task listener, a risk of hanging promises by throwing instead of rejecting in the default case, and a deviation from Web SDK parity regarding the rejection value for canceled tasks.

Comment thread packages/storage/lib/modular.ts
@mikehardy mikehardy force-pushed the @mikehardy/storage-upload-bytes branch from 82a80e8 to 375bac0 Compare May 1, 2026 22:40
@mikehardy mikehardy force-pushed the @mikehardy/storage-upload-bytes branch from 375bac0 to 734019b Compare May 4, 2026 00:33
…teraction

Hermes Blob implementation is lacking, and breaks storage uploads done using
firebase-js-sdk which expects a full-featured implementation if "Blob" exists
on globalThis

if you temporarily hide the Blob implementation firebase-js-sdk will fallback
to a different data upload method, then binary storage uploads will work

So, make a custom binary upload pathway for storage when using firebase-js-sdk
and hide Blob in it, but only if platform is not in fact web
@mikehardy mikehardy force-pushed the @mikehardy/storage-upload-bytes branch from 824c2b6 to 8eb4ae1 Compare May 5, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Workflow: Needs Review Pending feedback or review from a maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants