Skip to content

multiple accounts + dev = Silent Crash in dev mode #1258

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

Closed
helloimalastair opened this issue Jun 11, 2022 · 13 comments · Fixed by #1293 or #1284
Closed

multiple accounts + dev = Silent Crash in dev mode #1258

helloimalastair opened this issue Jun 11, 2022 · 13 comments · Fixed by #1293 or #1284
Assignees
Labels
bug Something that isn't working

Comments

@helloimalastair
Copy link
Contributor

🐛 Bug report

Describe the bug

When running dev mode in wrangler, service will run for a second, prompt for an account, and then silently crash.

Reproduce the bug

A list of steps to reproduce the bug.

  1. Run wrangler dev with project that previously worked.
  2. Wait a second while the dev instance boots up.
  3. Select Account from list.

Expected behavior

After running wrangler dev, wrangler should prompt for your account BEFORE starting up, and then should not crash unexpectedly.

Environment and versions

Fill out the following information about your environment.

  • operating system: macOS Monterey v12.4
  • output of wrangler -V: 2.0.9
  • output of node -v: v18.2.0
  • content of wrangler.toml:
name = "gitdiffbot"
compatibility_date = "2022-05-25"
main = "dist/index.js"

kv_namespaces = [
  {binding = "KV", id = KVID, preview_id = KVID}
]

[triggers]
crons = ["0 */6 * * *"]
@helloimalastair helloimalastair added the bug Something that isn't working label Jun 11, 2022
@threepointone threepointone transferred this issue from cloudflare/wrangler-legacy Jun 14, 2022
@threepointone threepointone moved this to Untriaged in workers-sdk Jun 14, 2022
@threepointone
Copy link
Contributor

This might be related to #1212

@threepointone
Copy link
Contributor

Could you try running wrangler login before starting wrangler dev and tell if the problem persists?

@petebacondarwin petebacondarwin added the awaiting reporter response Needs clarification or followup from OP label Jun 14, 2022
@andon
Copy link

andon commented Jun 15, 2022

@threepointone I'm experiencing the same bug. It happens from [email protected]. The problem persists when I run wrangler login before wrangler dev.

@threepointone
Copy link
Contributor

Can you confirm that you have multiple account ids?

@andon
Copy link

andon commented Jun 15, 2022

@threepointone Yes I do. 3 accounts.

@threepointone
Copy link
Contributor

Yeah I think we have a bug here, sorry about that. This is probably a blocker for anyone with multiple accounts. We'll discuss it today and figure out a fix/workaround. Sorry! Please downgrade to 2.0.9 for now.

@threepointone
Copy link
Contributor

threepointone commented Jun 15, 2022

A workaround could be to enter account_id = "your account id" in wrangler.toml (or as an env var like CLOUDFLARE_ACCOUNT_ID=youraccountid wrangler dev)

@andon
Copy link

andon commented Jun 15, 2022

Yeah I think we have a bug here, sorry about that. This is probably a blocker for anyone with multiple accounts. We'll discuss it today and figure out a fix/workaround. Sorry! Please downgrade to 2.0.9 for now.

Downgrade to 2.0.8 ;)

The workaround with adding the account-id in wrangler.toml does the trick. Thanks.

@petebacondarwin
Copy link
Contributor

So I guess it was one of my two commits: b44cc26 or 101342e that caused this regression...

@threepointone
Copy link
Contributor

I suspect it's because we have 2 things listening for input, the hotkeys bar, and the dropdown select in multiple accounts.

@threepointone threepointone changed the title Silent Crash in dev mode multiple accounts + dev = Silent Crash in dev mode Jun 15, 2022
@petebacondarwin
Copy link
Contributor

Oh! Right. Maybe even the fact that we are trying to call Ink.js render() for the dropdown from within an Ink.js component that is already being rendered :-/

@threepointone
Copy link
Contributor

That's probably it!

petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 18, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in `wrangler dev` as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for `wrangler dev`).

This fix refactors the `ChooseAccount` component so that it can be used directly within another component.

Fixes cloudflare#1258
@petebacondarwin petebacondarwin moved this from Untriaged to In Review in workers-sdk Jun 18, 2022
@petebacondarwin petebacondarwin removed the awaiting reporter response Needs clarification or followup from OP label Jun 18, 2022
@petebacondarwin
Copy link
Contributor

The fix is up for review...

petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 18, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in `wrangler dev` as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for `wrangler dev`).

This fix refactors the `ChooseAccount` component so that it can be used directly within another component.

Fixes cloudflare#1258
@petebacondarwin petebacondarwin self-assigned this Jun 20, 2022
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 20, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).

This fix refactors the ChooseAccount component so that it can be used directly within another component.

Fixes cloudflare#1258
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 20, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).

This fix refactors the ChooseAccount component so that it can be used directly within another component.

Fixes cloudflare#1258
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 20, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).

This fix refactors the ChooseAccount component so that it can be used directly within another component.

Fixes cloudflare#1258
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 21, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).

This fix refactors the ChooseAccount component so that it can be used directly within another component.

Fixes cloudflare#1258
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 22, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).

This fix refactors the ChooseAccount component so that it can be used directly within another component.

Fixes cloudflare#1258
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 22, 2022
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).

This fix refactors the ChooseAccount component so that it can be used directly within another component.

Fixes cloudflare#1258
petebacondarwin added a commit that referenced this issue Jun 22, 2022
)

* move generate helpers to user directory

* don't report cache usage when only writing to the cache

* Do not patch the console when using ink to render a simple static output

* Mock out `setEncoding()` when mocking `process.stdin`

* capture the last std.write() call not the first

* move user.tsx into the user directory

* Move env vars getters into own file

* Use common GET memberships mock in tests

* fix: do not crash in `wrangler dev` if user has multiple accounts

When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).

This fix refactors the ChooseAccount component so that it can be used directly within another component.

Fixes #1258

* fixup! fix: do not crash in `wrangler dev` if user has multiple accounts

* fix: do not hang waiting for account choice when in non-interactive mode

The previous tests for non-interactive only checked the stdin.isTTY, but
you can have scenarios where the stdin is interactive but the stdout is not.
For example when writing the output of a `kv:key get` command to a file.

We now check that both stdin and stdout are interactive before trying to
interact with the user.
Repository owner moved this from In Review to Done in workers-sdk Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
4 participants