httptoolkit / httptoolkit-desktop

Electron wrapper to build and distribute HTTP Toolkit for the desktop
https://httptoolkit.com
GNU Affero General Public License v3.0
606 stars 83 forks source link

`npm run start:dev` tries to start the server #11

Closed evanrolfe closed 4 years ago

evanrolfe commented 4 years ago

Hi, first of all great piece of software you have created. This is a tiny bug but occurs when you are following the READMEs to run this locally so might hinder people looking to contribute.

Steps to reproduce

  1. Start httptoolkit-server by cloning and running npm start
  2. Start httptoolkit-ui by cloning and running npm run start:web
  3. Start httptoolkit-desktop by cloning and running npm run start:dev

What happens You get an error:

HTTP Toolkit hit an error: spawn /home/evan/Code/httptoolkit/httptoolkit-desktop/httptoolkit-server/bin/httptoolkit-server ENOENT.

This is because its trying to start the server even though the server is already running. The README says:

npm run start:dev - runs the desktop app, with no built-in server

If I remove these lines then the desktop app starts fine. So I think maybe that just needs to be wrapped in an if statement to check if start or start:dev has been run.

pimterry commented 4 years ago

Hi @evanrolfe, thanks for the report.

This is supposed to work by using a dummy httptoolkit-server binary, which runs but does nothing. That should be set up by setup-dev.js.

The goal here is to have the core desktop code be the same for all cases, so in the real app it runs the real server, and in dev it runs a stub server whilst your real server runs elsewhere.

I'm not sure why that's not working for you. I'm pretty sure it is working on my machine, so there must be a difference somewhere. Any chance you can look into it a little further?

That setup-dev.js script should have been run by prestart:dev, which gets run automatically by npm before npm run start:dev. That should have created an httptoolkit-server/bin/httptoolkit-server file, with a tiny script inside. Clearly the desktop app isn't finding or successfully running that script though.

Any idea which step has failed there? Can you see prestart:dev running? Do you have the httptoolkit-server folder in the root of your clone, does it have a runnable script inside?

evanrolfe commented 4 years ago

Ok, I've found the issue. It looks likesetup-dev.js is expecting me to have the httptoolkit-server repo existing inside httptoolkit-desktop? But what I had done was to clone the desktop, server and ui all to the same directory i.e.

~/Code/httptoolkit$ ls
httptoolkit-desktop  httptoolkit-server  httptoolkit-ui

So maybe the readme needs to make it clear that its expecting that structure?

Cheers

pimterry commented 4 years ago

Ah, that would explain it. It definitely shouldn't be doing that! If there is no httptoolkit-server directory, it should create one from scratch, this sounds like a bug.

I'll try to look into this soon, but I'm currently trying to wrap up a million other things before Christmas. Any chance you've got a minute to open a PR that tweaks the script to fix this?

pimterry commented 4 years ago

Fixed by #12