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

wasmer login is incredibly buggy #4712

Open
fschutt opened this issue May 17, 2024 · 7 comments
Open

wasmer login is incredibly buggy #4712

fschutt opened this issue May 17, 2024 · 7 comments
Labels
priority-high High priority issue
Milestone

Comments

@fschutt
Copy link
Contributor

fschutt commented May 17, 2024

Describe the bug

Encountered a multitude of bugs when trying out wasmer login / wasmer deploy, just thought I'd give you guys a heads up:

  1. wasmer deploy X tries to search for a "deploy" user and run a package. Could be done better IMO:
$ wasmer deploy test
error: Unable to find "deploy" in the registry
│   1: error sending request for url (https://registry.wasmer.io/graphql): error trying to connect: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
│   2: error sending request for url (https://registry.wasmer.io/graphql): error trying to connect: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
│   3: error trying to connect: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
╰─▶ 4: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
  1. wasmer deploy crashes if user is not logged in, doesn't wait for y/n input (and shows a stack trace instead of allowing the user to log in):
$ wasmer deploy
WARN: You need to be logged in to deploy an app.
? Do you want to login now? (y/n) ›error: IO error: Unzulässige Funktion. (os error 1)
╰─▶ 1: Unzulässige Funktion. (os error 1)
  1. wasmer whoami completely fails if wasmer login browser authentication is done with GitHub authentication:
$  wasmer login
Opening auth link in your default browser: https://wasmer.io/auth/cli?nonce_id=nnc_1R8EIJt0iqx2&secret=q3NpjJ20hfjUI8FGqPLjCHBGfa6OD68XOUbdew6LsqA

< ... create a new account with GitHub ...>
< webpage shows I am logged in (green)>
CTRL + C

$ wasmer login // again, since I now have an account on the wasmer registry
error: error sending request for url (https://registry.wasmer.io/graphql): error trying to connect: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
│   1: error trying to connect: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
╰─▶ 2: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)

$ wasmer login
Opening auth link in your default browser: https://wasmer.io/auth/cli?nonce_id=nnc_YK53Ixtxi03R&secret=wVh24jNAciPnqoKlNmFQfQkytJn8_eMCDU7xdy1zq7M
error: Zugriff verweigert (os error 5)
Waiting for session...

< ... Browser shows "CLI authentication success page" ... >

$ wasmer whoami
error: not logged into registry "https://registry.wasmer.io/graphql"

$ wasmer login
Opening auth link in your default browser: https://wasmer.io/auth/cli?nonce_id=nnc_PRvJI4t7ia6R&secret=wEfy_C7zmmU4U604U1vCjtc7j882Ecb1fZW_fjsrz8U

$ wasmer login
error: error sending request for url (https://registry.wasmer.io/graphql): error trying to connect: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
│   1: error trying to connect: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)
╰─▶ 2: Eine vorhandene Verbindung wurde vom Remotehost geschlossen. (os error 10054)

$ wasmer login
Opening auth link in your default browser: https://wasmer.io/auth/cli?nonce_id=nnc_DR9EIBtjiZZR&secret=d4zVaTc1aGP3mTbI7aetmod9_qR3_3w-Mw-DWtNR4N4
error: Zugriff verweigert (os error 5)
Waiting for session...

< ... web browser shows "Completed Authentication" page ... >

$ wasmer whoami
error: not logged into registry "https://registry.wasmer.io/graphql"

$ wasmer whoami
error: not logged into registry "https://registry.wasmer.io/graphql"

So yeah, I cannot log in at all, it seems. Therefore, I cannot use wasmer login, therefore I cannot try wasmer deploy. It might be better to decouple wasmer deploy from wasmer login at least for the app creation phase. It also seems that the server backend sometimes has timeout issues, would be better to implement retries instead of failing on the first try. The backend says "Authentication successful", but wasmer whoami fails. Also, not sure if it's a good idea to encode secrets in the URL?

Also just as a note: if generating UUIDs, use short-uuid in order to avoid characters that can mess up in the URL or in a bash script! Do not use underscores or dashes in UUIDs, only "browser-safe" characters (base54)!

wasmer -vV; rustc -vV

wasmer 4.3.0 (36c1ece 2024-05-10)
binary: wasmer-cli
commit-hash: 36c1ece0d0691243e49d550df0258160d888698a
commit-date: 2024-05-10
host: x86_64-pc-windows-msvc
compiler: singlepass,cranelift,llvm

rustc -vV
rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-pc-windows-msvc
release: 1.75.0
LLVM version: 17.0.6

Using wasmer-windows.exe from the 4.3.1 release.

@theduke
Copy link
Contributor

theduke commented May 17, 2024

Hey @fschutt , long time now see, how are you doing?

Thanks for the feedback. We just had a big revamp of the CLI... there is some fallout.

The problem with wasmer deploy test is that it doesn't take an argument, and (still!) has the hacky fallback to trying to find a "deploy" package on the registry.

That should be fixed by detecting if a relevant command exists...

cc @xdoardo @syrusakbary

@syrusakbary
Copy link
Member

Thanks for creating the issue, we'll investigate and try to address most of the things you commented asap!

@syrusakbary
Copy link
Member

Three action items from our side:

  1. wasmer deploy ... should not go through the run flow
  2. wasmer deploy should wait for y/n input
  3. wasmer login should finish if the browser completes with: < ... Browser shows "CLI authentication success page" ... >

@syrusakbary syrusakbary added the priority-high High priority issue label May 21, 2024
@syrusakbary syrusakbary added this to the v4.4 milestone May 21, 2024
@xdoardo
Copy link
Contributor

xdoardo commented May 24, 2024

Hello!

I spent some time investigating these issues, and I'll write here what I found out.

Regarding the first one - wasmer deploy X reducing to wasmer run deploy... - this PR was merged and is part of the 4.3.1 release. The current behaviour is this:

$ wasmer deploy X
error: unexpected argument 'X' found

Usage: wasmer deploy [OPTIONS]

For more information, try '--help'.

Regarding the rest, we had no previous experience of the login and deploy issues mentioned here - since we mostly use macOS and linux, I tried to reproduce the issues in a Windows VM (Parallels), but I was not able to (sorry in advance for the hard-to-read screenshots).

I downloaded the latest wasmer binary as shown in the docs ($v="v4.3.1"; iwr https://win.wasmer.io/ -useb | iex)

Trying to login:

image

Trying to deploy:

image

As can be seen in the screenshots, I experienced a different issue than those reported here - I guess due to spurious failing SSL handshakes - but which should be fixed with retries as suggested by @fschutt.

Last thing, the wasmer app create subcommand has, per the release 4.3.1, the --offline flag that allows users to create locally the files needed to deploy an app. As of now, this does not allow to use templates, which are not embedded in the binary itself but are downloaded from the registry.

@fschutt
Copy link
Contributor Author

fschutt commented May 29, 2024

Okay, (1) is fixed. It seems that (2) was related to my terminal, I used the Git Bash shell. When I used Windows Terminal, it worked as expected.

I have some criticism regarding the flow of wasmer create flow.

  • (3) seems to be because of permission problems when saving the token. The CLI can't save the token because of permission errors. The problem fixed itself when I restarted the Windows terminal in "administrator" mode, however, I should not need to do this. I have no idea where the credentials get saved, but the .wasmer directory is still empty. The token gets saved in the WASMER_DIR, but this fails because the default installation path is C://Program Files (x86)/Wasmer, which is admin protected. Whatever, I am logged in now.
  • wasmer.io/login page doesn't have a button for "login with GitHub / Google" (unlike wasmer.io/signup), which is annoying, you have to sign into your browser first and then restart "wasmer login". I did get an error "this nonce has already been used", so I had to restart "wasmer login" multiple times. I personally like to just use GitHub for login, then get an auth token that I'm logged in.
  • for UX I would ping registry.wasmer.io first to see if it is available and use retries if it doesn't work on the first try, to reduce the problem of network outage errors causing UX problems (and later on maybe CI problems)
  • in the app create flow, the question Enter the name of the package? wasmer/hello seems to be hard coded. I expected it to take into account the previous two questions (owner / package name)
  • in the app create flow, the flow is stopped if you are not logged in and the questions are confusing ("Do you want to deploy the app now? yes / Do you want to log in? no -> exit") - I expected it to continue the flow as in "--offline" mode.

wasmer deploy is still not functional, after I now logged in:

 wasmer app create --offline
✔ Who should own this app? · fschutt
✔ What should be the name of the app? · m4p
Creating app from a package name running in offline mode
✔ Enter the name of the package · fschutt/m4p                         // <- I had to retype this from wasmer/hello
✔ Do you want to deploy the app now? · no                    // <- I am using --offline, so obviously no

Result: nothing happened, I expected it to create an app but no folder was generated, nothing.

EDIT: It created the app.yaml file, but didn't tell me about it. Please prompt the user with some documentation about app.yaml! From a user perspective, I have no idea what exactly happened now, or what I just "created". I'd expect a "fschutt/m4p" folder (similar to cargo new) where I could copy my stuff / app / wasmer.toml file into and then tell it to deploy, at least that's how I understand wasmer edge.

I also have no idea what the difference between wasmer deploy and wasmer app create is, IMO they should be aliases of each other.

After that I ran wasmer deploy but I can't create the app because it doesn't exist yet (???).

$ wasmer whoami
logged into registry "https://registry.wasmer.io/graphql" as user "fschutt"

$ wasmer deploy

Deploying app m4p (fschutt) to Wasmer Edge...

error: could not create app in the backend
│   1: could not publish app
╰─▶ 2: GraphQL API failure: The package release `fschutt/m4p@latest` does not exist on the registry.

Yes no shit sherlock... I am trying to create the first version of it! Of course it doesn't exist yet. Now I have to open my browser to "create an app" (I want to create an HTTP server so I can serve my website maps4print.com, whose backend is written in 100% Rust), and run into the next problem, https://docs.wasmer.io/edge/quickstart/http-server is a dead link (the correct link is https://docs.wasmer.io/edge/quickstart/rust-http-server). Please have a dead link scanner or something on docs.wasmer.io, so that this doesn't happen again.

Okay, now when I created the app I forgot to pass in --template because I didn't know that that was a thing. So I have to destroy the app.yaml file and redo it. Also I have to know beforehand which value the --template flag accepts, this is not great. It would be best to query available templates from GraphQL during the user flow, then present to the user to select the template (hugo, axum-rust, js, php, etc.)

@syrusakbary
Copy link
Member

(3) seems to be because of permission problems when saving the token

That's a good catch, we are going to see how we can fix it. Do you happen to remember how you installed Wasmer so we can try to reproduce the issue? (via cargo install? Using the pwr command?)

wasmer.io/login page doesn't have a button for "login with GitHub / Google"

Right now we require you to input the username first, as the login with Github/Google was causing an issue, but we can easily reenable the commented behavior on the login page. (being able to "login with Github / Google" from the /login page directly, no username input required)

for UX I would ping registry.wasmer.io first to see if it is available and use retries if it doesn't work on the first try

We can investigate this further, we have discussed internally and we don't have a clear idea on how to solve this (perhaps via a --retries flag?). We need to research a bit more on the ideal case.

in the app create flow, the question Enter the name of the package? wasmer/hello

Oh, I think I know why things were more confusing here. Apps and packages are two different entities.
You can deploy an app that has no "named package" attached, that means that we don't need a package name to deploy an app (please see the CDN example: https://github.com/wasmer-examples/cdn-wasmer-starter, where the wasmer.toml doesn't have an specific package name).

Just to clarify, the information that we prompt is about the owner and name of the app (not of the package).

In any case, we can move from:

It seems you are trying to create a new app!
✔ Who should own this app? · syrusakbary
✔ What should be the name of the app? · aasa
✔ What would you like to deploy? · Choose an existing package
? Enter the name of the package › wasmer/hello
It seems you are trying to create a new app!
✔ Who should own this app? · syrusakbary
✔ What should be the name of the app? · aasa
✔ What would you like to deploy? · Choose an existing package
? Enter the name of the package to deploy (eg. wasmer/hello) › 

in the app create flow, the flow is stopped if you are not logged in and the questions are confusing ("Do you want to deploy the app now? yes / Do you want to log in? no -> exit")

@xdoardo will investigate further

@fschutt
Copy link
Contributor Author

fschutt commented May 31, 2024

That's a good catch, we are going to see how we can fix it. Do you happen to remember how you installed Wasmer so we can try to reproduce the issue? (via cargo install? Using the pwr command?)

No, downloading wasmer-windows.exe and double-clicking. The default installation directory is set to C://Program Files (x86)/Wasmer, so that's what WASMER_DIR is set to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-high High priority issue
Projects
None yet
Development

No branches or pull requests

4 participants