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

🐛 BUG: npm start after forced login results in a lot of warnings #693

Closed
jkup opened this issue Mar 25, 2022 · 3 comments · Fixed by #695
Closed

🐛 BUG: npm start after forced login results in a lot of warnings #693

jkup opened this issue Mar 25, 2022 · 3 comments · Fixed by #695
Assignees

Comments

@jkup
Copy link
Contributor

jkup commented Mar 25, 2022

What version of Wrangler are you using?

0.0.0-8f7ac7b

What operating system are you using?

Mac

Describe the Bug

I installed wrangler@alpha and then ran an init followed by npm start. I wasn't logged in so I was bounced to the login flow and after I authenticated I got a bunch of terminal spam even though it was a brand new project. Here is my terminal output.

☁ npm install -g wrangler@alpha

added 46 packages, and audited 47 packages in 6s

found 0 vulnerabilities
☁  wrangler --version
0.0.0-8f7ac7b
☁  wrangler init test
 ⛅️ wrangler 0.0.0-8f7ac7b
---------------------------
Using npm as package manager.
✨ Successfully created wrangler.toml
No package.json found. Would you like to create one? (y/n)

added 46 packages, and audited 47 packages in 1s

found 0 vulnerabilities
✨ Created package.json
Would you like to use TypeScript? (y/n)

added 2 packages, and audited 49 packages in 3s

found 0 vulnerabilities
✨ Created tsconfig.json, installed @cloudflare/workers-types into devDependencies
Would you like to create a Worker at src/index.ts? (y/n)
✨ Created src/index.ts

To start developing your Worker, run `cd test && npm start`
To publish your Worker to the Internet, run `npm run publish`cd test
☁  npm start

> [email protected] start
> wrangler dev

 ⛅️ wrangler 0.0.0-8f7ac7b
---------------------------
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
Attempting to login via OAuth...
Successfully logged in.
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
⬣ Listening at http://localhost:8787
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
It looks like you have used Wrangler 1's `config` command to login with an API token.
This is no longer supported in the current version of Wrangler.
If you wish to authenticate via an API token then please set the `CLOUDFLARE_API_TOKEN` environment variable.
waiting for connection...
waiting for connection...
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ B to open a browser, D to open Devtools, L to turn on local mode, X to exit                                            │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
@jkup jkup added the bug label Mar 25, 2022
@threepointone threepointone added this to the 2.0 milestone Mar 25, 2022
@threepointone threepointone moved this to Must-have in workers-sdk Mar 25, 2022
@jkup
Copy link
Contributor Author

jkup commented Mar 25, 2022

Worth noting:

  1. After ctrl+c'ing the process and running wrangler dev again it worked without errors
  2. I'm only 2/3 being able to reproduce this

@caass caass self-assigned this Mar 25, 2022
@petebacondarwin
Copy link
Contributor

Oh!! Haha, we don't re-read the config file once the login has occurred, so we don't realise that it has changed.

@petebacondarwin
Copy link
Contributor

Luckily we even have a helper for that, which was only being used in the tests so far: reinitialiseAuthTokens().

@caass caass linked a pull request Mar 29, 2022 that will close this issue
petebacondarwin pushed a commit that referenced this issue Mar 30, 2022
If a user hasn't logged in and then they run a command that needs a login they'll get bounced to the login flow.
The login flow (if completed) would write their shiny new OAuth2 credentials to disk, but wouldn't reload the
in-memory state. This led to issues like #693, where even though the user was logged in on-disk, wrangler
wouldn't be aware of it.

We now update the in-memory login state each time new credentials are written to disk.
Repository owner moved this from Must-have to Done in workers-sdk Mar 30, 2022
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 a pull request may close this issue.

4 participants