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

Handle non-200 status codes when downloading WEBC files #3919

Merged
merged 4 commits into from
May 28, 2023

Conversation

Michael-F-Bryan
Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan commented May 26, 2023

I've refactored the wasmer_wasix::http module to use more types from the http crate. This lets us implement a HttpResponse::is_ok() method in terms of the http::StatusCode we get back, rather than making each client implementation decide whether a request failed or not.

That means when a package has recently been released and the backend hasn't finished generating a *.webc file for it (which we get a 503 for), instead of seeing an error like this:

$ wasmer run-unstable https://wapm.io/wasmer/wasmer-io
error: Unable to resolve "https://wapm.io/wasmer/wasmer-io"
│   1: Unable to detect the WEBC version
╰─▶ 2: Expected the magic bytes to be "\x00webc", but found "The w"

You will see something like this:

$ wasmer run-unstable https://wapm.io/wasmer/wasmer-io
error: Unable to resolve "https://wapm.io/wasmer/wasmer-io"
│   1: GET request to "https://wapm.io/wasmer/wasmer-io" failed
|   2: 503 Service Unavailable (Retry after: 5 minutes)

Copy link
Contributor

@theduke theduke left a comment

Choose a reason for hiding this comment

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

Nice!

@Michael-F-Bryan Michael-F-Bryan marked this pull request as ready for review May 28, 2023 11:44
@Michael-F-Bryan Michael-F-Bryan enabled auto-merge May 28, 2023 11:45
@Michael-F-Bryan Michael-F-Bryan merged commit 9c81cb8 into master May 28, 2023
@Michael-F-Bryan Michael-F-Bryan deleted the reqwest-errors branch May 28, 2023 12:58
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