Problem/Motivation
In the constructor of the ArtisanLibraries object, a function initDevMode() is called.
This function calls \Drupal::httpClient()->get($dev_url) . When there is no development server available, this function seems to time out only after 30 seconds.
When creating a custom theme with artisan starterkit, the constructor is called when implementing hook_library_info_alter().
When moving the theme to a production environment, the development server was not activated.
And after every drupal cache rebuild, a fresh load of the site would take more than 5 minutes because of this (constructor is called 11 times).
Steps to reproduce
Proposed resolution
It is possible to reduce the timeout with this code:
$response = \Drupal::httpClient()->get($dev_url, [
'timeout' => 0.1,
'connect_timeout' => 0.1
]);
$this->devMode = ($response->getStatusCode() == 200);
But it would be even better to skip this check when not running in dev mode.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork artisan-3584948
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
avpadernoComment #3
omarlopesinoWorking on a MR. I will also update documentation to make it clear development server should not be configured in production environments, and using config_split / settings.local.php instead.
Comment #4
frouco commentedMy proposal is to completely remove the Vite dev mode support and all the associated hook_library_info_alter logic.
Comment #6
omarlopesinoAbout #4 I disagree and I would not treat it in this issue. Let's create a new one and discuss it. Dropping dev support means dropping support for Vite Hot module replacement which is a great feature IHMO. It is a major decision. Please, open an issue an explain why we don't get benefit of a feature that allows a easy live reload per component.
About my self comment at #3, I didn't remember that, if no URL is set, a default one is set. That is a mistake because we should support not configuring the DEV mode. The current configuration is not predictable.
So, I have created a MR with several fixes:
Ready to review.
Comment #7
omarlopesinoComment #8
omarlopesinoComment #11
omarlopesinoFixed on 3.x and 2.x branches