Skip to content

useStorageDownloadURL crashes when there is no file in firebase storage #535

Closed

Description

@kirilligum

Version info

React:
17.0.2
Firebase:
9.6.6
ReactFire:
4.2.1
Other (e.g. Node, browser, operating system) (if applicable):
nodejs v16.16.0

Test case

Steps to reproduce

in the code

  const storage = useStorage();
  const catRef = ref(storage, 'kyc/upload/wy_id');
  const { status, data: imageURL } = useStorageDownloadURL(catRef);

Expected behavior

if the file is not there, the status should reflect

Actual behavior

the website is blank and in the browser's console:
Uncaught FirebaseError: Firebase Storage: Object 'kyc/upload/wy_id' does not exist. (storage/object-not-found)

Activity

  1. self-assigned this
    on Aug 4, 2022
  2. steveoh commented on Dec 7, 2022

    @steveoh

    I'm seeing same issue.

  3. adamkubina1 commented on Apr 4, 2023

    @adamkubina1

    Same issue for me...
    Has anybody found a working solution for this by any chance?

  4. steveoh commented on Apr 4, 2023

    @steveoh

    I stopped using reactfire for this and used the base firebase constructs and it fixed a few issues in our app.

  5. prixrak commented on Jun 4, 2023

    @prixrak

    the same..

  6. added
    v5Planned for v5
    and removed
    v5Planned for v5
    on Jul 15, 2026
  7. added a commit that references this issue on Jul 15, 2026
    b113bc3
  8. added a commit that references this issue on Jul 27, 2026
    0b70a12
  9. tyler-reitz commented on Jul 27, 2026

    @tyler-reitz
    Contributor

    Fixed by #735, merged into the v5 branch.

    useStorageDownloadURL no longer throws when the object is missing. In non-suspense mode (the default, and what your snippet uses) the hook now returns status: 'error' with the underlying error available as error, so your original expectation that "the status should reflect" it now holds:

    const { status, data: imageURL, error } = useStorageDownloadURL(catRef);
    if (status === 'error') {
      // error.code === 'storage/object-not-found'
    }

    There's a regression test asserting exactly storage/object-not-found for a nonexistent file.

    In suspense mode (suspense: true) errors are still thrown, so a React Error Boundary can catch them. That is intentional and unchanged.

    Please note this ships in 5.0.0, not in any 4.x release, since the change is breaking for anyone currently relying on an Error Boundary in non-suspense mode. See the v4 to v5 upgrade guide for the migration path.

  10. locked and limited conversation to collaborators on Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions