cli icon indicating copy to clipboard operation
cli copied to clipboard

Auto close tunnel if interupted or exited

Open Loocos opened this issue 2 years ago • 5 comments

Hi,

We always need to do tunnel:close when the tunnel got exited when a rebuild is done on the environment or if we CTRL+C

It would be great to close the tunnel in this both case.

Is there any reason of this behaviour ?

Thanks

Loocos avatar Aug 19 '23 05:08 Loocos

I'm not sure how to reproduce the issue.

Is this with tunnel:single?

pjcdawkins avatar Aug 21 '23 19:08 pjcdawkins

@pjcdawkins Exactly yes

Loocos avatar Aug 23 '23 12:08 Loocos

I've updated my CLI to the latest version (4.8.6) through Scoop and it get worst. Now I can't open tunnel anymore...

After opening the tunnel using tunnel:single, I quit it with CTRL + C, try to reopen and get :

$ platform tunnel:single
Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given in phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Pipes/WindowsPipes.php:74
Stack trace:
#0 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Pipes/WindowsPipes.php(74): fclose()
#1 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(1371): Symfony\Component\Process\Pipes\WindowsPipes->__construct()
#2 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(281): Symfony\Component\Process\Process->getDescriptors()
#3 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(209): Symfony\Component\Process\Process->start()
#4 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(234): Symfony\Component\Process\Process->run()
#5 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Shell.php(224): Symfony\Component\Process\Process->mustRun()
#6 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Shell.php(128): Platformsh\Cli\Service\Shell->runProcess()
#7 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/CredentialHelper/Manager.php(336): Platformsh\Cli\Service\Shell->execute()
#8 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/CredentialHelper/Manager.php(115): Platformsh\Cli\CredentialHelper\Manager->exec()
#9 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/ApiToken/CredentialHelperStorage.php(30): Platformsh\Cli\CredentialHelper\Manager->get()
#10 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/TokenConfig.php(34): Platformsh\Cli\ApiToken\CredentialHelperStorage->getToken()
#11 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(270): Platformsh\Cli\Service\TokenConfig->getApiToken()
#12 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(445): Platformsh\Cli\Service\Api->getConnectorOptions()
#13 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(1162): Platformsh\Cli\Service\Api->getClient()
#14 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(593): Platformsh\Cli\Service\Api->getHttpClient()
#15 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/CommandBase.php(697): Platformsh\Cli\Service\Api->getProject()
#16 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/CommandBase.php(1055): Platformsh\Cli\Command\CommandBase->getCurrentProject()
#17 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/CommandBase.php(1587): Platformsh\Cli\Command\CommandBase->selectProject()
#18 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/Tunnel/TunnelSingleCommand.php(36): Platformsh\Cli\Command\CommandBase->validateInput()
#19 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Command/Command.php(255): Platformsh\Cli\Command\Tunnel\TunnelSingleCommand->execute()
#20 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Application.php(1010): Symfony\Component\Console\Command\Command->run()
#21 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Application.php(347): Symfony\Component\Console\Application->doRunCommand()
#22 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Application.php(255): Platformsh\Cli\Application->doRunCommand()
#23 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun()
#24 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/bin/platform(32): Symfony\Component\Console\Application->run()
#25 C:\Users\flore\AppData\Local\Temp\psh-go-8.0.29-4.8.6\psh-4.8.6(10): require('...')
#26 {main}
  thrown in phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Pipes/WindowsPipes.php on line 74

And if I try to close it (which was working before) :

$ platform tunnel:close
Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, bool given in phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Pipes/WindowsPipes.php:74
Stack trace:
#0 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Pipes/WindowsPipes.php(74): fclose()
#1 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(1371): Symfony\Component\Process\Pipes\WindowsPipes->__construct()
#2 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(281): Symfony\Component\Process\Process->getDescriptors()
#3 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(209): Symfony\Component\Process\Process->start()
#4 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Process.php(234): Symfony\Component\Process\Process->run()
#5 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Shell.php(224): Symfony\Component\Process\Process->mustRun()
#6 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Shell.php(128): Platformsh\Cli\Service\Shell->runProcess()
#7 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/CredentialHelper/Manager.php(336): Platformsh\Cli\Service\Shell->execute()
#8 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/CredentialHelper/Manager.php(115): Platformsh\Cli\CredentialHelper\Manager->exec()
#9 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/ApiToken/CredentialHelperStorage.php(30): Platformsh\Cli\CredentialHelper\Manager->get()
#10 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/TokenConfig.php(34): Platformsh\Cli\ApiToken\CredentialHelperStorage->getToken()
#11 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(270): Platformsh\Cli\Service\TokenConfig->getApiToken()
#12 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(445): Platformsh\Cli\Service\Api->getConnectorOptions()
#13 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(1162): Platformsh\Cli\Service\Api->getClient()
#14 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Service/Api.php(593): Platformsh\Cli\Service\Api->getHttpClient()
#15 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/CommandBase.php(697): Platformsh\Cli\Service\Api->getProject()
#16 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/CommandBase.php(1055): Platformsh\Cli\Command\CommandBase->getCurrentProject()
#17 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/CommandBase.php(1587): Platformsh\Cli\Command\CommandBase->selectProject()
#18 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/Tunnel/TunnelCommandBase.php(265): Platformsh\Cli\Command\CommandBase->validateInput()
#19 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Command/Tunnel/TunnelCloseCommand.php(33): Platformsh\Cli\Command\Tunnel\TunnelCommandBase->filterTunnels()
#20 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Command/Command.php(255): Platformsh\Cli\Command\Tunnel\TunnelCloseCommand->execute()
#21 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Application.php(1010): Symfony\Component\Console\Command\Command->run()
#22 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/src/Application.php(347): Symfony\Component\Console\Application->doRunCommand()
#23 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Application.php(255): Platformsh\Cli\Application->doRunCommand()
#24 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun()
#25 phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/bin/platform(32): Symfony\Component\Console\Application->run()
#26 C:\Users\flore\AppData\Local\Temp\psh-go-8.0.29-4.8.6\psh-4.8.6(10): require('...')
#27 {main}
  thrown in phar://C:/Users/flore/AppData/Local/Temp/psh-go-8.0.29-4.8.6/psh-4.8.6/vendor/symfony/process/Pipes/WindowsPipes.php on line 74

Hope it helps you figure out

Loocos avatar Aug 23 '23 12:08 Loocos

The error is gone after uninstall/install and clear cache. But the behaviour of closing the tunnel everytime is still there. Is there any reason of that?

Loocos avatar Aug 25 '23 03:08 Loocos

The fclose() error seems to be related to the CredentialHelper not the tunnels (thanks for pasting the backtrace).

But the behaviour of closing the tunnel everytime is still there. Is there any reason of that?

Sorry I still don't understand what happens here. What does the tunnel:single output show when the environment is rebuilt, or on ctrl+C?

For me (on Linux) the command exits when the SSH connection breaks:

image

pjcdawkins avatar Sep 21 '23 11:09 pjcdawkins