suppress exposing some ports
akosyakov opened this issue Β· comments
During Node.js debugging I see notifications to expose ports, it gets annoying. It would be nice if it is possible to mark some ports like not exposable and suppress new notifications.
In the .gitpod.yml you can say
- port: 43534
onOpen: ignore
@HorizonShadow Oof, that's a lot of ports!
If you know these ports in advance, you can silence the pop-ups with something like this in your .gitpod.yml
:
ports:
- port: 3001
onOpen: ignore
- port: 29851
onOpen: ignore
- port: 28593
onOpen: ignore
- port: 21581
onOpen: ignore
EDIT: (I should have read prior comments before replying.) I don't think we have a way to ignore port ranges yet, unfortunately. π Would be a useful feature for meteor though!
EDIT 2: Something like this maybe:
ports:
- port: 20000-30000
onOpen: ignore
I was also made aware of a project where programs open many ports, leading to several popup messages in Gitpod:
The intention I would like to express is: "I have listed all relevant ports of my project, I don't care about the rest, I can't predict what other ports will be opened because programs choose random ports numbers and I don't want to bother investigating based on which strategy they do that".
I thought we could have something like.
ports:
- port: 20000
onOpen: open-preview
- ignoreAllOtherPorts: true
or even better, define the semantics of @jankeromnes suggestion to be like this:
ports:
- port: 20000
onOpen: open-preview
- port: 1000-30000
onOpen: ignore
This would ignore ports 1000-30000
, except the ones that have been explicitly opened (20000
).
Another idea could be to throttle the Gitpod port pop-ups, only opening the first 2 or 3, and then say something like:
There are 12 other ports with activity [View active ports] [Ignore all unspecified ports]
?
EDIT: This would have the benefit of working just fine, even if you don't know / care about .gitpod.yml
.
In addition to that, I propose to introduce a user setting for ignoring port notifications.
Some people want to use Gitpod to demo their code:
- the person that prepares the demo has deep knowledge about
.gitpod.yml
- the person that views the demo should not have a single false-positive popup.
I have same issues with node debugging on random ports. I cannot specify which port can be ignored, one notification is not so annoying, but still distracting.
Lot's of good suggestions!
I like the simplicty of ignoreAllOtherPorts
but would like to make it fit better with the existing concepts by allowing ranges and a wildcard *
in addition to the port numbers.
Example:
ports:
- port: 3000
onOpen: open-preview
- port: *
onOpen: ignore
One could argue that the current default is.
ports:
- port: *
onOpen: notify
I also think #493 would improve the UX a lot.
Improving notifications generally makes a lot of sense, too. We should generalize that in Theia.
I would really love to have the possibility to mask notifications for port ranges or even better for all those ports in .gitpod.yml
that I don't specifically mark as to-be-notified.
When I start my application in Gitpod, the IDE is literally flooded with tons of notifications.
We should maybe add onOpen: ignore-no-expose
to allow non auto-exposing for ranges.
I'd like to implement port ranges like so (implicit priority: "single port" > "specific port ranges" > "*"):
ports:
- port: 3000
onOpen: open-preview
- port: 3001-4000
onOpen: notify
- port: *
onOpen: ignore
However, my concern is that until now, every port listed in ports:
gets exposed in the workspace (whether onOpen:
is open-browser
, open-preview
, notify
or ignore
).
But when you do:
- port: *
onOpen: ignore
I guess your intent is not to suddenly expose all the ports of your workspace, but just to silence the notifications.
Thus, I would like to:
- rename
ignore
toexpose
(same behavior: expose the port silently and do nothing else) - add a new action that is both silent and doesn't expose the port, called something like
block
orignore-no-expose
as suggested above
We could keep backwards compatibility by continuing to allow ignore
as a synonym for expose
.
(EDIT: Maybe renaming ignore
to expose
is optional. It seems it's already used quite a lot.)
Actually (after many design iterations) I think that the following behavior would be best to silence noisy port notifications, without unintended side-effects, nor over-complicated configurations:
- Port ranges in
.gitpod.yml
don't pre-expose ports - When a port from a range becomes active and the IDE opens it, it gets automatically exposed first
- (no change to the existing
onOpen
actions)
Current behavior (to illustrate):
ports:
- port: 3000 # exposed
- port: 3001
onOpen: open-preview # exposed
- port: 3002
onOpen: notify # exposed
- port: 3003
onOpen: ignore # exposed
New with port ranges:
ports:
- port: 4000-4999 # (same as notify)
- port: 5000-5999
onOpen: open-preview # not exposed (but a port that triggers a preview will get exposed first)
- port: 6000-6999
onOpen: notify # not exposed (but clicking on "Open Preview" or "Open Browser" will expose that port)
- port: *
onOpen: ignore # not exposed (if you really want to expose a port here, either configure it specifically, or manually expose from the Ports view)
I often use ignore
and need that port being exposed. This is always the case for any API endpoints.
Would be good to auto-expose on ignore
, open-browser
, open-preview
.
But not on notify
(default) and a new ignore-no-expose
.
The notify will open up a notification allowing to open in browser
or open in preview
which will auto-expose.
Hi @jankeromnes, thank you for your proposal!
I also think (like @svenefftinge) that we should support the use-case of exposing ports without raising notifications for them.
Besides this, I think I understand how @svenefftinge and you arrive at different approaches. @svenefftinge's design has two assumptions:
- listing a port in
.gitpod.yml
means it is exposed. onOpen
is only about the action that's triggered when an app starts listening on that port, not exposure.
If a user is not aware of these two assumptions he/she is very like to misunderstand the semantic's of ignore
: He/she may think the port is ignored by Gitpod: not exposed, no notification.
Thank you for the quick feedback on my proposal!
I agree with:
- making
Open Browser
andOpen Preview
actions expose the port on-the-fly if necessary - changing
onOpen: notify
to not pre-expose the port
I often use
ignore
and need that port being exposed. This is always the case for any API endpoints.
My gut feeling here is that you'll never want to use public Gitpod URLs like https://31457-abcd.ws-eu.gitpod.io
when using port ranges.
I think that you'll either have:
- A single API port (or just a few), that you can list individually in
.gitpod.yml
- Too many API ports, that you'll be able to list as a port range like
- port: 30000-40000
, but that you won't ever use public Gitpod URLs for (e.g. unexposedlocalhost:31457
access server-side will be enough)
Because of 1. and 2., I'm suggesting to continue pre-exposing single ports (e.g. - port: 8081
, regardless of onOpen
) but to not pre-expose port ranges (e.g. - port: 30000-40000
). Do you think that's reasonable?
Another way to put my question is, what do you think should happen when users do:
- port: *
onOpen: ignore
?
(Side-note, we can't use the syntax - port: *
, as our parser thinks *
is an empty YAML alias. Instead, it should be - port: "*"
, or just - default:
.)
Update: I'm currently implementing something like this:
ports:
- port: 3000-3999
onOpen: ignore
The Good: By default, this will have the desired effect of silencing the notifications of all ports in the specified range (because of onOpen: ignore
).
The Bad: This will also have the unfortunate side-effect of automatically exposing all active ports in that range (i.e. just like automatically clicking "Expose" on all these notifications, regardless of onOpen
).
In the interest of time, I'll ship this version first, and follow up with improvements later. (Also, I don't like the name ignore-no-expose
, but if that's the preferred way to silence notifications without exposing all ports, I'll implement it.)
Thank you @jankeromnes for being on this.
Having ignore-no-expose
(or any equivalent tag) available would be great in my setting.
Update: Port ranges are now implemented and should be deployed very soon (today). π
Additionally, contrary to the previous update, port ranges with onOpen: ignore
will not be automatically exposed for now (i.e. for port ranges, ignore
currently behaves like a ignore-no-expose
would):
ports:
- port: 2000-2999
onOpen: open-preview # auto-exposed
- port: 3000-3999
onOpen: ignore # NOT auto-exposed
This is slightly inconsistent with individual ports, in order to preserve backward-compatibility:
ports:
- port: 4000
onOpen: open-preview # auto-exposed
- port: 5000
onOpen: ignore # also auto-exposed
I also think that it makes sense that way:
- If you have a single ignored port, it might be a backend that you'd like to access via a Gitpod preview URL like
https://5000-abcd.ws-eu.gitpod.io
- But if it's an entire port range that's ignored, you're probably not going to bother with preview URLs (i.e. you just want to silence them, or you just want to use
localhost:<dynamic port>
server-side). And even if you really want a preview URL, you can always manually expose ports from theOpen Ports
view, or set the range'sonOpen
to something different thanignore
.
Note that this is very easy to tweak further in the future. Please let me know if you'd like the auto-exposing behavior to be changed.
Final update: Port ranges are now live on gitpod.io! Please try them out and report any bugs. π
EDIT: For example,
- here is a test repository with pre-configured port ranges
- you can try to open any port in a range by running
python3 -m http.server 3500
in the terminal
Working gracefully!
Thanks a lot for this nice addition π