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

🐛✨ [Frontend] Automatically pull latest frontend version (nocache) #7054

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

odeimaiz
Copy link
Member

@odeimaiz odeimaiz commented Jan 17, 2025

What do these changes do?

There is currently a mechanism in place to detect whether the webserver has a different version of frontend compared to the one the user's browser has. If that's the case a "Reload" button, that requests the newest version, is shown to the users.

image

In order to figure out that the user's browser is actually using a cached (different) version, we compare the vcsRefClient stamped in a configuration file (that can be cached) and the vcsRefClient that is included in the response to the /app-summary resource (which is NOT cached).

When the user hits the oSparc's "Reload" button, what oSparc does is add a random query parameter to the cacheable resources, forcing the browser to pull the latest version.

But when the user hits browser's reload button, the old-cached version might be loaded, hence the oSparc's Reload button would show up again, bringing the user to an endless loop:

In the animation:

  • User loads the application: the browser uses the cached version (1)
  • What we execute in the console mimics what oSparc's Reload button does: add the no-cache=random_number query parameter and force the pull of the newest version (2)
  • When the user reloads the browser, the cached version (1) is loaded again...

ReloadButton

In this PR, the application loading pieces were tuned after compilation, making this random query parameter always be present.

nocache

Related issue/s

closes #6697

How to test

Dev-ops checklist

@odeimaiz odeimaiz self-assigned this Jan 17, 2025
@odeimaiz odeimaiz added this to the Singularity milestone Jan 17, 2025
@odeimaiz odeimaiz added the a:frontend issue affecting the front-end (area group) label Jan 17, 2025
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.57%. Comparing base (3d01781) to head (824982a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7054   +/-   ##
=======================================
  Coverage   87.57%   87.57%           
=======================================
  Files        1629     1629           
  Lines       63454    63454           
  Branches     2047     2047           
=======================================
  Hits        55569    55569           
  Misses       7549     7549           
  Partials      336      336           
Flag Coverage Δ *Carryforward flag
integrationtests 63.78% <ø> (+0.01%) ⬆️
unittests 85.96% <ø> (ø) Carriedforward from 3d01781

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
api 76.84% <ø> (ø)
pkg_aws_library 93.49% <ø> (ø)
pkg_dask_task_models_library 97.09% <ø> (ø)
pkg_models_library 91.45% <ø> (ø)
pkg_notifications_library 84.57% <ø> (ø)
pkg_postgres_database 88.29% <ø> (ø)
pkg_service_integration 70.02% <ø> (ø)
pkg_service_library 73.89% <ø> (ø)
pkg_settings_library 90.49% <ø> (ø)
pkg_simcore_sdk 85.38% <ø> (ø)
agent 96.45% <ø> (ø)
api_server 90.54% <ø> (ø)
autoscaling 96.09% <ø> (ø)
catalog 90.66% <ø> (ø)
clusters_keeper 99.24% <ø> (ø)
dask_sidecar 91.26% <ø> (ø)
datcore_adapter 93.18% <ø> (ø)
director 76.51% <ø> (ø)
director_v2 91.30% <ø> (ø)
dynamic_scheduler 97.21% <ø> (ø)
dynamic_sidecar 89.75% <ø> (ø)
efs_guardian 90.46% <ø> (ø)
invitations 93.44% <ø> (ø)
osparc_gateway_server ∅ <ø> (∅)
payments 92.66% <ø> (ø)
resource_usage_tracker 89.46% <ø> (ø)
storage 89.57% <ø> (ø)
webclient ∅ <ø> (∅)
webserver 85.95% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d01781...824982a. Read the comment docs.

@odeimaiz odeimaiz marked this pull request as ready for review January 17, 2025 14:32
@odeimaiz odeimaiz changed the title 🐛✨ [Frontend] Always force hard reload 🐛✨ [Frontend] Automatically pull latest frontend version (nocache) Jan 17, 2025
@calys
Copy link

calys commented Jan 17, 2025

💪

print(f"Updating vcs_ref_client: {index_file_path}")
file.write(data)

boot_file_paths = _get_output_file_paths("boot.js")
Copy link
Member

@pcrespov pcrespov Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIP: if you would instead use pathlib.Path, your code would become more compact

from pathlib import Path

boot_file_paths: list[Path] = [] # assume we have this


for boot_file_path in boot_file_paths:
    if boot_file_path.is_file():
        print(f"Updating URL_PARAMETERS: {boot_file_path}")

        boot_file_path.write_text(
            boot_file_path.read_text().replace(
                "addNoCacheParam : false",
                "addNoCacheParam : true",
            )
        )

and the same with all the operations to compose paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:frontend issue affecting the front-end (area group)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Endless Loop with Reload Notification
3 participants