-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
@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 |
There was a problem hiding this 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:
- script starts and creates a new BeaconManager.
- On DOMContentLoaded , the script waits for rocket_beacon_data.delay
- 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.
dist/wpr-beacon.js
Outdated
if (10 <= scriptTime) { | ||
const delay = this.config.delay + 10; | ||
if (delay <= scriptTime) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to remove.
@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. |
dfd0547
to
318fdd9
Compare
Changed base branch to develop. see https://wp-media.slack.com/archives/CUT7FLHF1/p1722593397186219?thread_ts=1722509646.276189&cid=CUT7FLHF1 |
There was a problem hiding this 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.
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
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
Documentation
Code style