Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is hyper still required as a dependency (in Errors)? #3607

Closed
trivikr opened this issue Jan 5, 2020 · 2 comments
Closed

Why is hyper still required as a dependency (in Errors)? #3607

trivikr opened this issue Jan 5, 2020 · 2 comments

Comments

@trivikr
Copy link
Contributor

trivikr commented Jan 5, 2020

I came across this question while going through the deno codebase.

  • reqwest was added an an http client in feat: use reqwest as http client #2822 (to replace hyper)
  • however, hyper still is used in deno_error.rs

    deno/cli/deno_error.rs

    Lines 219 to 229 in 76e44dd

    impl GetErrorKind for hyper::Error {
    fn kind(&self) -> ErrorKind {
    match self {
    e if e.is_canceled() => ErrorKind::HttpCanceled,
    e if e.is_closed() => ErrorKind::HttpClosed,
    e if e.is_parse() => ErrorKind::HttpParse,
    e if e.is_user() => ErrorKind::HttpUser,
    _ => ErrorKind::HttpOther,
    }
    }
    }

Why is this dependency on hyper required?

@bartlomieju
Copy link
Member

bartlomieju commented Jan 12, 2020

We use reqwest for our HTTP client which relies on hyper. reqwest::Error does not contain a lot of useful information but we can downcast it to underlying hyper error to get that info. Unfortunately reqwest does not reexport any types from hyper so we need explicit dependency on it. I guess it doesn't matter much because it's already used by reqwest anyway.

This brings another topic which is #2635.

A quick grep through a code base does not yield a single usage of:

  • ErroKind.HttpUser
  • ErroKind.HttpClosed
  • ErroKind.HttpCanceled
  • ErroKind.HttpParse

So we should consider removing them and rename ErrorKind.HttpOther to ErroKind.Http.

CC @ry

@bartlomieju
Copy link
Member

Fixed in #3662

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

No branches or pull requests

2 participants