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

Tools -> DDEV -> Share does not output the ngrok status #53

Open
2 tasks done
jonaseberle opened this issue May 19, 2022 · 9 comments
Open
2 tasks done

Tools -> DDEV -> Share does not output the ngrok status #53

jonaseberle opened this issue May 19, 2022 · 9 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jonaseberle
Copy link

jonaseberle commented May 19, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Are you sure that this bug is related to this DDEV Integration Plugin?

  • I am sure

Describe the bug

Running ddev share outputs

ngrok                                                                                                                                    (Ctrl+C to quit)
                                                                                                                                                         
Session Status                online                                                                                                                     
Account                       jonas.eberle@xxx.xx (Plan: Free)                                                                                        
Update                        update available (version 3.0.3, Ctrl-U to update)                                                                         
Version                       3.0.3                                                                                                                      
Region                        Europe (eu)                                                                                                                
Latency                       16.072771ms                                                                                                                
Web Interface                 http://127.0.0.1:4040                                                                                                      
Forwarding                    https://4cd1-2001-16b8-2b73-3800-c58c-bf71-362a-9716.eu.ngrok.io -> http://127.0.0.1:49239                                 
                                                                                                                                                         
Connections                   ttl     opn     rt1     rt5     p50     p90                                                                                
                              51      2       0.82    0.17    0.08    0.43                                                                             

It includes the output of the dynamic ngrok domain (if you are on the free plan) which is important information to use it.

Running it with the plugin (via Tools -> DDEV -> Share) shows only this in the integrated PhpStorm terminal:

ddev share
Running /home/jonas/bin/ngrok http http://127.0.0.1:49239 -region eu 

Steps to reproduce

  1. Click Tools -> DDEV -> Share

Compare with ddev share in your favorite terminal.

Additional context

ngrok shows a kind of "terminal full screen app" while it is running. That means it repositions the cursor to output text at arbitrary locations. Somehow this does not work with the integrated terminal.
Nota bene: top (which probably uses a similar technique) works ok in the integrated terminal.

Tested on:

  • Manjaro
  • DDEV version v1.19.2-10-ge3dc718b (main)
  • ngrok version 3.0.3
  • Terminal settings:
    image

Is the output OK on other OSes/shells?

@jonaseberle jonaseberle added the bug Something isn't working label May 19, 2022
@nico-loeber nico-loeber added this to the v1.0.0 milestone May 19, 2022
@nico-loeber
Copy link
Contributor

Thank you for reporting this @jonaseberle.
We already know that the share feature isn't implemented well yet.
There is already an issue about a better integration here: #8

But I wasn't aware of the bug you describe. It might have something to do with a recent refactoring of the terminal actions (using a PTY) I did. I will check what I can do to solve this. Thanks!

@nico-loeber
Copy link
Contributor

nico-loeber commented May 26, 2022

Unfortunately, I can't reproduce your issue.
Yes, repositioning of the cursor does not work properly, as content updates are appended and not replaced, but there is no content missing for me.
I have tested this with Windows 11 and in WSL (Ubuntu 20.04).

@SpraxDev could you maybe test this on Debian?
@juulliian could maybe give feedback how this behaves on MacOS?

As I mentioned before, I plan to optimize the functionality of ddev share, e.g. by providing the share url in the UI with the option to automatically copy it to the clipboard and other convenience features like this. But this has no high priority to me right now.

C:\Windows\system32\wsl.exe --distribution Ubuntu --exec /bin/bash -l -c "export DDEV_NONINTERACTIVE=true && ddev share"
ngrok                                                                                                   (Ctrl+C to quit)

Session Status                connecting
Version                       3.0.3
Latency                       calculating...
Web Interface                 http://127.0.0.1:4040

Connections                   ttl     opn     rt1     rt5     p50     p90     
                              0       0       0.00    0.00    0.00    0.00    







Session Status                online
Session Expires               1 hour, 59 minutes
Terms of Service              https://ngrok.com/tos
Version                       3.0.3
Region                        Europe (eu)
Latency                       calculating...
Web Interface                 http://127.0.0.1:4040
Forwarding                    https://****-**-**-**-**.eu.ngrok.io -> http://127.0.0.1:52494

Connections                   ttl     opn     rt1     rt5     p50     p90     
                              0       0       0.00    0.00    0.00    0.00

@SpraxDev
Copy link
Contributor

SpraxDev commented May 27, 2022

@SpraxDev could you maybe test this on Debian?

I'm having the exact same issue where the IDE Terminal does not show anything from ngrok while the command in the terminal does as expected:
grafik

App/System info:
grafik

@jonaseberle
Copy link
Author

jonaseberle commented May 27, 2022

I just realized that it might not have anything to do with the Jetbrains internal terminal:

When disabling the plugin "Terminal (bundled)" the Tools -> DDEV -> share command still works.

And when running ddev share manually in the internal Termnal it looks fine:

image

It seems to be more about this part

https://github.com/php-perfect/ddev-intellij-plugin/blob/main/src/main/java/de/php_perfect/intellij/ddev/cmd/DdevRunnerImpl.java#L95-L102

called from

https://github.com/php-perfect/ddev-intellij-plugin/blob/main/src/main/java/de/php_perfect/intellij/ddev/cmd/DdevRunnerImpl.java#L56-L60

@nico-loeber
Copy link
Contributor

nico-loeber commented May 28, 2022

It seems to be more about this part

https://github.com/php-perfect/ddev-intellij-plugin/blob/main/src/main/java/de/php_perfect/intellij/ddev/cmd/DdevRunnerImpl.java#L95-L102

This is the configuration of the process, using a pseudo terminal, which is required for many terminal features. At least on Windows and WSL this setup works quite well.

As I can not reproduce this in my environments, I might need your help @SpraxDev.
Maybe disabling the PTY on operating systems other than Windows is all that is needed?

Thank you both for your detailed feedback, @jonaseberle, @SpraxDev!

@nico-loeber
Copy link
Contributor

Hi @jonaseberle,
@SpraxDev and I have been doing a debugging session for a couple of hours now and all we could find out is that the ngrok binary does not produce any output in this context. This is only the case on Linux operating systems. On Windows and Ubuntu inside WSL, it works as expected (More or less, repositioning of the cursor does not work well).
The ngrok documentation mentions that the "ui" is turned off if the terminal is not a tty.
As you have already seen in the code, we use a PtyProcess. The default terminal in PHPStorm is also a PtyCommandLine, as far as I know. So I'm not sure why this doesn't work on Linux distributions. Maybe there is some environment variable missing.
If you have any ideas, please let me know.

A possible workaround might be to not use the so-called "ui" mode and enable info logging on the console instead. This leads to much better results on all operating systems in the PHPStorm terminal, as the information is logged progressively.
The ngrok domain is part of this output.
To enable the log mode and configure its level, we would need to pass ngrok parameters using the ddev share command, which is currently not possible.

@rfay
Copy link
Collaborator

rfay commented Jun 3, 2022

One thing to be aware of, and I'm sure you already are, is that ngrok has changed quite a lot in the last couple of months, with a new version and a new config file. Just putting that out there.

@nico-loeber
Copy link
Contributor

One thing to be aware of, and I'm sure you already are, is that ngrok has changed quite a lot in the last couple of months, with a new version and a new config file. Just putting that out there.

Thank you for the hint!
The behavior on the standard PHPStorm terminal and in the run terminal is different. As this happens on the same system with the same configuration this has to be something related to environment variables or the terminal type, I think.
Due to the fact there is no source code for the ngrok binary it is hard to find out what might cause this change in behavior as both terminals are tty and this is the only documented indicator for outputting the UI or not.

@nico-loeber
Copy link
Contributor

As this bug is a bit more complicated than expected and we plan to overhaul the ngrok integration in 1.1 anyway, I will delay this for the 1.1 release. Sorry.

@nico-loeber nico-loeber modified the milestones: v1.0.0, v1.1.0 Jun 16, 2022
@nico-loeber nico-loeber self-assigned this Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants