cli: "SyntaxError: Unexpected end of JSON input" if browser login flow not completed

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

  1. Install the CLI via Homebrew on OS X 10.14.3.
  2. Run heroku autocomplete as suggested by the post-install console output.
  3. Press spacebar at the “press any key to open the browser” prompt.
  4. Close the newly opened browser tab, since not wanting to log in right now.
  5. When CLI times out, the following is output:
Building the autocomplete cache... ?

Opening browser to https://cli-auth.heroku.com/auth/browser/REDACTED
heroku: Waiting for login... !
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at HTTP._parse (/usr/local/Cellar/heroku/7.22.7/libexec/node_modules/http-call/lib/http.js:342:30)

What is the expected behavior?

  • The autocomplete command does not trigger the login flow.
  • The CLI gracefully handles the user not completing the browser login flow. ie: After N seconds of waiting for the auth callback, the CLI exits with an appropriate message (eg “Timed out waiting for browser sign in”) and no stack trace.

This was using: heroku/7.22.7 darwin-x64 node-v11.10.1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 23

Most upvoted comments

Hey guys, in case you are having this issue using any CLI command (for instance heroku apps)

What worked for me was:

  • Edit the config.json file. (In my case it didn’t have any content)
  • If your file is empty like mine, just add a valid empty JSON object as content:
{
}

In my case I’m on a Mac, the path for the file is: your-user-folder/.local/share/heroku/config.json

I was able to solve the login issue using heroku login --interactive

Ubuntu 20, In my case, I just removed the file and it is recreated on login.

Any solutions? Same problem from using Cloud9:

heroku: Waiting for login... !
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at HTTP._parse (~/.local/share/heroku/client/7.21.0/node_modules/http-call/lib/http.js:342:30)

thanks bro

@sammymwangangi Thanks it’s work for me

worked for me too, thanks sammy

i can not thank you enough sammymwanga~it’s worked.

Thank you Sammy…

I was able to solve the login issue using heroku login --interactive

you did it, thanks a lot

This Worked for me too! Thanks a lot!

I was able to solve the login issue using heroku login --interactive

you did it, thanks a lot

I can’t thank you enough sammymwanga! it’s worked:)

Thanks alot sammymwanga ! it’s worked for me !

Reinstalling heroku cli solved the problem for me…