Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

give option to not open browser when previewing #256

Closed
samuelcolvin opened this issue Jun 15, 2019 · 15 comments · Fixed by #816
Closed

give option to not open browser when previewing #256

samuelcolvin opened this issue Jun 15, 2019 · 15 comments · Fixed by #816
Labels
feature Feature requests and suggestions

Comments

@samuelcolvin
Copy link

Hi, great talk last Tuesday at cloudflare connect in London on workers and rust.

Wrangler looks awesome, building and testing workers looks like it's got a lot nicer in the last 6 months.

Would be great if I could preview workers without having to open a browser (or have one opened for me) for every preview.

A few things that would make this possible:

  • option to not open a browser on wrangler preview (obviously)
  • connect to the websocket for receiving console output and log it to the terminal - quite how this is displayed is an open question since one can't click to expand output in the terminal as one can in a browser console
  • get more details about the request to the worker and response, eg. headers and body - something like the output from httpie.

There's a gist here (old and ugly code, sorry) that demonstrates much of what I'm asking for.

Failing all this, one step would be to reuse the same browser tab for each preview so I don't end up with 50 old cloudflare worker tabs, although maybe that's a limitation of chrome?

@xortive
Copy link
Contributor

xortive commented Jun 17, 2019

#252 is in progress and adds wrangler preview --livereload which will build your worker and update the preview tab (without making a new one) on file changes automatically.

@samuelcolvin
Copy link
Author

Thanks, this fixes the work around mentioned at the end, but does not help with the original request.

Terminal only previews/development would be wonderful.

@ashleygwilliams
Copy link
Contributor

@samuelcolvin i think adding a flag --browser/--browserless (i'm not sure what the default should be yet) that controls whether the browser responds is a great idea, and was something i simply ran out of time to build.

would you be interested in submitting a PR? if not i think this is achievable for an upcoming release :)

@ashleygwilliams ashleygwilliams changed the title browserless previewing give option to not open browser when previewing Jun 21, 2019
@ashleygwilliams ashleygwilliams added this to the 1.1.0 milestone Jun 21, 2019
@ashleygwilliams ashleygwilliams added feature Feature requests and suggestions PR welcome labels Jun 21, 2019
@samuelcolvin
Copy link
Author

How many of the features above should --browserless implement?

I'm guessing that just not opening the browser would be a good start?

Showing request and response headers wouldn't be that hard (though you could go a lot further and highlight the body etc.), the real bulk of the work would be on printing the console log.

@ashleygwilliams
Copy link
Contributor

i would imagine that this would be for preview and would encompass the http request commands we currently support, get (default), and post.

i think we should definitely add headers to the console output as well! this could be a separate PR tho, if we wanted to keep them small (though i'd be happy with either).

@samuelcolvin
Copy link
Author

Okay, I'll try and work on it when I get a chance, but feel free for anyone to take over if I don't get around to it.

@ashleygwilliams ashleygwilliams removed this from the 1.1.0 milestone Jun 24, 2019
@paulbhartzog-holo
Copy link

@samuelcolvin i think adding a flag --browser/--browserless (i'm not sure what the default should be yet) that controls whether the browser responds is a great idea, and was something i simply ran out of time to build.

would you be interested in submitting a PR? if not i think this is achievable for an upcoming release :)

I like this approach, and I would argue that NOT opening the browser should be the default, but maybe that's just me. I'd rather have --browser than --browserless :-)

Any movement on this?

@samuelcolvin
Copy link
Author

been too busy to work on this, that's not going to change too soon.

I suspect that while many of us would prefer not to open a browser it will be hard to persuade cf to change the default.

@lucas-pelton
Copy link

In a similar (and potentially off-topic, sorry) experience, I'm running wrangler preview --watch on a machine that is terminal-only and therefore can't launch a browser window. I must open a browser window on another machine.

I'm interested to know if the URL for the current instance of wrangler preview --watch is discoverable in any way so that I can launch my own browser window.

@ashleygwilliams
Copy link
Contributor

hey! we actually are prioritizing this work this quarter, and hope to implement a terminal only preview, a la "wrangler cURL", and parameterize the option of opening the browser cc @samuelcolvin

@samuelcolvin
Copy link
Author

Thanks for the cc, afraid I haven't been working on cf workers recently so unlikely I'll be able to help implement this.

@ashleygwilliams
Copy link
Contributor

it's all good! @EverlastingBugstopper is going to be focusing on it :) if you have any suggestions or thoughts, feel free to share!

@samuelcolvin
Copy link
Author

My main point would be that a websocket connection and worker console log in the terminal as demonstrated by my gist above would make a massive different for those of us fond of using the terminal.

--browerless, or perhaps better respecting the BROWSER env. variable like create react app, would obviously be the simplest win.

@ashleygwilliams
Copy link
Contributor

thank you for sharing @samuelcolvin !

@lucas-pelton
Copy link

@ashleygwilliams Do you know if the URL for the current instance of wrangler preview --watch is discoverable in any way? I'm running the command on a terminal-only machine and I want to launch the preview URL in a browser window on a separate machine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Feature requests and suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants