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

adjust beacon timeout using delay value wp-media/wp-rocket--#6741 #5

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

Khadreal
Copy link
Contributor

@Khadreal Khadreal commented Jul 29, 2024

Description

Adjust timeout, make the value dynamic

Fixes wp-media/wp-rocket#6741

Documentation

User documentation

Adjust the timeout to use the filter value from the backend.

Technical documentation

Explain how this code works. Diagram & drawings are welcomed.

Type of change

  • Enhancement (non-breaking change which improves an existing functionality).

New dependencies

List any new dependencies that are required for this change.

Risks

List possible performance & security issues or risks, and explain how they have been mitigated.

Checklists

Feature validation

  • I validated all the Acceptance Criteria. If possible, provide sreenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Documentation

  • I prepared the user documentation for the feature/enhancement and shared it in the PR or the GitHub issue.
  • The user documentation covers new/changed entry points (endpoints, WP hooks, configuration files, ...).
  • I prepared the technical documentation if needed, and shared it in the PR or the GitHub issue.

Code style

  • I wrote self-explanatory code about what it does.
  • I wrote comments to explain why it does it.
  • I named variables and functions explicitely.
  • I protected entry points against unexpected inputs.
  • I did not introduce unecessary complexity.
  • I listed the introduced external dependencies explicitely on the PR.
  • I validated the repo-specific guidelines from CONTRIBUTING.md.

@Khadreal Khadreal requested a review from wordpressfan July 29, 2024 08:21
@Khadreal Khadreal self-assigned this Jul 29, 2024
@Khadreal Khadreal added the enhancement New feature or request label Jul 29, 2024
Miraeld
Miraeld previously approved these changes Jul 29, 2024
remyperona
remyperona previously approved these changes Jul 31, 2024
@MathieuLamiot
Copy link
Contributor

@Khadreal There are conflicts to solve it seems, this branch should be updated against the trunk I guess.

Here are steps to be able to test the script with WP Rocket: https://wp-media.slack.com/archives/CUT7FLHF1/p1722526242449019?thread_ts=1722509646.276189&cid=CUT7FLHF1

Copy link
Contributor

@MathieuLamiot MathieuLamiot left a comment

Choose a reason for hiding this comment

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

It seems that the expected behavior is not clear based on the discussion you are having. The expected behavior is:
if the init method runs for more than 10 seconds, then the script status result is failed.

The sequence is as follows:

  1. script starts and creates a new BeaconManager.
  2. On DOMContentLoaded , the script waits for rocket_beacon_data.delay
  3. After the delay, init() is called.

The issue originally was that the timer was starting at point 1. Hence, the timer was running during the delay. This is something we don't want, hence the GH issue.

So, to solve this, the only thing we need is to do
this.scriptTimer = /* @__PURE__ */ new Date();
at the beginning of init() instead of when instanciating BeaconManager

Therefore, we are sure the timer only runs during init() and the delay is not impacting it, regardless of its value.

Comment on lines 291 to 292
if (10 <= scriptTime) {
const delay = this.config.delay + 10;
if (delay <= scriptTime) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to remove.

@MathieuLamiot
Copy link
Contributor

@DahmaniAdame to confirm my latest comment. But I think the original issue jumped directly into a solution (doing delay + 10) which caused the confusion, since there is a better way to handle this.

@Khadreal Khadreal force-pushed the enhancement/6741-adjust-beacon-timeout branch from dfd0547 to 318fdd9 Compare August 2, 2024 09:52
@MathieuLamiot MathieuLamiot changed the base branch from trunk to develop August 2, 2024 11:24
@MathieuLamiot
Copy link
Contributor

Changed base branch to develop. see https://wp-media.slack.com/archives/CUT7FLHF1/p1722593397186219?thread_ts=1722509646.276189&cid=CUT7FLHF1

@Khadreal Khadreal dismissed stale reviews from remyperona and Miraeld via 318fdd9 August 5, 2024 15:08
Copy link

@hanna-meda hanna-meda left a comment

Choose a reason for hiding this comment

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

This PR looks good. Tested with steps from TC.
Thank you.

@Khadreal Khadreal merged commit 0137c76 into develop Aug 7, 2024
1 check passed
@Khadreal Khadreal deleted the enhancement/6741-adjust-beacon-timeout branch October 16, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust lcp-beacon.min.js timeout to be relative to rocket_lcp_data.delay
5 participants