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

Starting with --local then turning off local mode crashes #18

Closed
geelen opened this issue Nov 16, 2021 · 3 comments · Fixed by #1212 or #1193
Closed

Starting with --local then turning off local mode crashes #18

geelen opened this issue Nov 16, 2021 · 3 comments · Fixed by #1212 or #1193
Assignees
Labels
bug Something that isn't working

Comments

@geelen
Copy link
Contributor

geelen commented Nov 16, 2021

Since you're never prompted to login & choose your accountId, you don't get that nor apitToken in the session, and you get this error

❯ npx wrangler dev index.js --local
⎔ Starting a local server...
⬣ Listening at http://localhost:8787

  ERROR  accountId is required

 node_modules/wrangler/wrangler-dist/index_node.js:98573:29

 98570:   }, []);
 98571: }
 98572: function Remote(props) {
 98573:   (0, import_assert.default)(props.accountId, "accountId is required");
 98574:   (0, import_assert.default)(props.apiToken, "apiToken is required");
 98575:   const token = useWorker({
 98576:     name: props.name,

 - Remote (node_modules/wrangler/wrangler-dist/index_node.js:98573:29)
 - renderWithHooks (node_modules/wrangler/wrangler-dist/index_node.js:18265:26)
 - mountIndeterminateComponent (node_modules/wrangler/wrangler-dist/index_node.js:20385:21)
 - beginWork (node_modules/wrangler/wrangler-dist/index_node.js:21172:22)
 - Object.invokeGuardedCallbackProd (node_modules/wrangler/wrangler-dist/index_node.js:22163:19)
 - invokeGuardedCallback (node_modules/wrangler/wrangler-dist/index_node.js:22250:39)
 - beginWork$1 (node_modules/wrangler/wrangler-dist/index_node.js:25088:15)
 - performUnitOfWork (node_modules/wrangler/wrangler-dist/index_node.js:24314:20)
 - workLoopSync (node_modules/wrangler/wrangler-dist/index_node.js:24265:13)
 - renderRootSync (node_modules/wrangler/wrangler-dist/index_node.js:24240:15)

⎔ Shutting down local server.
@Electroid Electroid added the bug label Nov 16, 2021
@threepointone threepointone self-assigned this Nov 16, 2021
threepointone added a commit that referenced this issue Nov 17, 2021
* 95% of Pages CLI

* Bindings

* Consistent descriptions

* Tidy imports

* Fix env.ASSETS.fetch

* Add error for no Worker script

* Linux support

* Move dependencies to devDependencies

* Cross-platform compatibility (stolen from Miniflare)

* Use new functions package

* Finish merging

* Move external deps to real deps

* Fix broken dep SHA?

* Support on-the-fly pages dev

* update package-lock.json with integrity hashes

(generated by running npm install at the root)

* Docs

Co-authored-by: Sunil Pai <[email protected]>
@Electroid Electroid added this to the 2.0 milestone Jan 20, 2022
@Electroid Electroid removed this from the 2.0 milestone Jan 31, 2022
@threepointone threepointone moved this to Must-have in workers-sdk Mar 17, 2022
@threepointone threepointone added this to the 2.0 milestone Mar 17, 2022
@threepointone threepointone moved this from Must-have to Should-have in workers-sdk Mar 21, 2022
@threepointone threepointone modified the milestones: 2.0, 2.1 Mar 27, 2022
@threepointone
Copy link
Contributor

A similar problem when passing --host, or routes, is that the zone id won't be available when starting from local and moving to remote mode.

@threepointone threepointone removed their assignment Mar 28, 2022
@threepointone threepointone moved this from Should-have to Must-have in workers-sdk Apr 4, 2022
yudai-nkt added a commit to yudai-nkt/homura that referenced this issue May 14, 2022
@petebacondarwin petebacondarwin modified the milestones: Selected for development, Backlog May 15, 2022
@petebacondarwin petebacondarwin moved this to Backlog in workers-sdk May 15, 2022
@petebacondarwin petebacondarwin removed this from the Backlog milestone May 15, 2022
@petebacondarwin petebacondarwin added bug Something that isn't working and removed type: bug labels May 16, 2022
@valgaze
Copy link

valgaze commented May 22, 2022

Steps

mkdir sampleworker
cd sampleworker
npx wrangler@2 init -y
npx wrangler@2 dev --local
# press l
  • Node v16.7 // npm 7.20.3
  • Wrangler v2

Error

accountId is required
node_modules/wrangler/wrangler-dist/cli.js:108881:35

If it needs an account id, maybe should error out if wrangler.toml is missing account_id per https://developers.cloudflare.com/workers/wrangler/configuration/

@sdarnell
Copy link

sdarnell commented Jun 2, 2022

Note that this is still an issue with version 2.0.7, and even if I previously logged in with wranger, AND actually specify an account_id in the wrangler.toml file (I also tried accountId).

@petebacondarwin petebacondarwin moved this from Backlog to Selected for development in workers-sdk Jun 7, 2022
@petebacondarwin petebacondarwin self-assigned this Jun 9, 2022
@petebacondarwin petebacondarwin moved this from Selected for development to In Progress in workers-sdk Jun 9, 2022
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Jun 9, 2022
Previously, if you are not logged in when running `wrangler dev` it will only try to log you in
if you start in "remote" mode. In "local" mode there is no need to be logged in, so it doesn't
bother to try to login, and then will crash if you switch to "remote" mode interactively.

The problem was that we were only attempting to login once before creating the `<Remote>` component.
Now this logic has been moved into a `useEffect()` inside `<Remote>` so that it will be run whether
starting in "remote" or transitioning to "remote" from "local".

The fact that the check is no longer done before creating the components is proven by removing the
`mockAccountId()` and `mockApiToken()` calls from the `dev.test.ts` files.

Fixes [#18](cloudflare#18)
@petebacondarwin petebacondarwin moved this from In Progress to In Review in workers-sdk Jun 9, 2022
petebacondarwin added a commit that referenced this issue Jun 9, 2022
…#1212)

Previously, if you are not logged in when running `wrangler dev` it will only try to log you in
if you start in "remote" mode. In "local" mode there is no need to be logged in, so it doesn't
bother to try to login, and then will crash if you switch to "remote" mode interactively.

The problem was that we were only attempting to login once before creating the `<Remote>` component.
Now this logic has been moved into a `useEffect()` inside `<Remote>` so that it will be run whether
starting in "remote" or transitioning to "remote" from "local".

The fact that the check is no longer done before creating the components is proven by removing the
`mockAccountId()` and `mockApiToken()` calls from the `dev.test.ts` files.

Fixes [#18](#18)
Repository owner moved this from In Review to Done in workers-sdk Jun 9, 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
6 participants