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

Command icon 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

lievenmoors created an issue. See original summary.

avpaderno’s picture

Version: 2.0.1 » 2.x-dev
omarlopesino’s picture

Assigned: Unassigned » omarlopesino
Status: Needs review » Needs work
Issue tags: +Needs documentation

Working 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.

frouco’s picture

My proposal is to completely remove the Vite dev mode support and all the associated hook_library_info_alter logic.

omarlopesino’s picture

Status: Needs work » Needs review
Issue tags: -Needs documentation

About #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:

  • If the Vite dev server configuration is empty, do not try to connect to it with the self host URL.
  • Add a timeout of 0.5 seconds. Adding 0.1 seconds is too much.
  • The description of the form elements is improved and its behavior will be predictable.

Ready to review.

omarlopesino’s picture

Assigned: omarlopesino » Unassigned
omarlopesino’s picture

Priority: Minor » Critical

  • omarlopesino committed a37bf429 on 2.x
    Issue #3584948: Prevent vite dev server to be resolved everytime
    

  • omarlopesino committed 963cb596 on 3.x
    Issue #3584948: Prevent vite dev server to be resolved everytime
    
omarlopesino’s picture

Status: Needs review » Fixed

Fixed on 3.x and 2.x branches

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.