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

Docs Command can not be cancelled when offline #50277

Closed
grafst opened this issue Feb 27, 2024 · 6 comments
Closed

Docs Command can not be cancelled when offline #50277

grafst opened this issue Feb 27, 2024 · 6 comments
Assignees

Comments

@grafst
Copy link

grafst commented Feb 27, 2024

Laravel Version

10.45.1

PHP Version

8.3.3

Database Driver & Version

No response

Description

The php artisan docs command cannot be interrupted using the CTRL+C key sequence when the system is offline. This issue prevents users from stopping the execution of the command in environments without an internet connection, leading to prolonged waits (>10sec) or the necessity to terminate the terminal session.

OS: macOS

Steps To Reproduce

  1. Ensure the system is offline or disconnect from the internet.
  2. Open the terminal application.
  3. Navigate to the Laravel project directory.
  4. Run the command php artisan docs.
  5. Attempt to cancel the operation using the CTRL+C key sequence.
@driesvints
Copy link
Member

@timacdonald do you maybe know?

@timacdonald
Copy link
Member

@grafst I'm not able to replicate the long connection wait time when disconnected.

If I turn my Wi-Fi off I get an error instantly.

We could reduce the connection timeout for the command, but any value feels kinda arbitrary to me.

@timacdonald
Copy link
Member

I will try manually pointing the docs command at a HTTP tarpit and see if I can recreate this tomorrow.

We can potentially trap signals to fix this (h/t @crynobone )

@grafst
Copy link
Author

grafst commented Mar 2, 2024

@timacdonald you are right when I'm completely offline It's fine. The error seems to arise when there is some kind of network error/delay...
Never heard of the tarpit-technique, very interesting :)
I wouldn't necessarily shorten the timeout, maybe some people on very slow networks will be greatful for a long timeout.
Trapping the abort signal would be a good idea either way I think...

@timacdonald
Copy link
Member

timacdonald commented Mar 3, 2024

@grafst, I've just replaced the HTTP request with one that takes 10 seconds.

// vendor/laravel/framework/src/Illuminate/Foundation/Console/DocsCommand.php
    /**
     * Fetch the documentation index from the Laravel website.
     *
     * @return \Illuminate\Http\Client\Response
     */
    protected function fetchDocs()
    {
+       echo 'making the HTTP request';
+
+       return $this->http->get("https://httpbin.org/delay/10");
-       return $this->http->get("https://laravel.com/docs/{$this->version()}/index.json");
    }

Then I run the command. The request is send but takes 10 seconds to respond, i.e., we are held on the HTTP line. When I press Ctrl-c the command instantly quits.

Screen Shot 2024-03-04 at 10 31 37 am

Do you have any ideas how I could replicate the issue further?

@driesvints
Copy link
Member

Closing this issue because it's inactive, already solved, old or not relevant anymore. Feel to open up a new issue if you're still experiencing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants