Skip to content

useFetch with invalid URL #64

Closed
Closed

Description

@CzBiX

Description

When an invalid URL is passed to useFetch, it throws an exception directly. This error isn't captured in the returned error field, nor can it be handled via the provided onError callback.
Throwing exceptions in react hooks also goes against best practices.

Steps To Reproduce

call useFetch with invalid URL,such as http://:8080

Current Behaviour

Throw an exception about invalid URL

Expected Behaviour

return the error in error or pass it into onError

Activity

  1. CzBiX commented on Dec 13, 2025

    @CzBiX
    Author
  2. j3lte commented on Dec 15, 2025

    @j3lte

    @CzBiX can you tell which version of @raycast/api and @raycast/utils you are using? I tested this invalid url against the useFetch smoketest (see tests/ folder) and it does return an error in the error field as well as the onError. Also, is this on Windows or on Mac?

  3. CzBiX commented on Dec 15, 2025

    @CzBiX
    Author

    @j3lte it's latest version. you can also try it in the current proxmox extension.

    fill the server url in configure with invalid url. then open the command.

    TypeError: Invalid URL
    
    dt:index.tsx:10:76
    
    ---
     7: import { VmTypeDropdown } from "@/components/VmTypeDropdown";
     8: 
     9: const Command = () => {
    10:   const { isLoading, data, revalidate, mutate, setType, showErrorScreen } = useVmList();
    11: 
    12:   return (
    13:     <ErrorGuard showErrorScreen={showErrorScreen}>
    ---
    
  4. mathieudutour commented on Aug 7, 2026

    @mathieudutour
    Member

    This should be fixed in 2.3

  5. added a commit that references this issue on Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Severity

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions