Code Monkey home page Code Monkey logo

Comments (4)

mostafa-hisham avatar mostafa-hisham commented on July 24, 2024

Scope a solution

  • Create submitted_at field in the RUCSS table

  1. update
    inc/Engine/Optimization/RUCSS/Database/Row/UsedCSS.php
    inc/Engine/Optimization/RUCSS/Database/Schemas/UsedCSS.php
    inc/Engine/Optimization/RUCSS/Database/Tables/UsedCSS.php
    to add a nullable timestamp column submitted_at

FYI: similar to what was done in this PR

  1. set the new column value to the current timestamp in
    public function create_new_job( string $url, string $job_id, string $queue_name, bool $is_mobile = false ) {

    and
    public function reset_job( int $id, string $job_id ) {
  • store more info in the message column

the message column is a longtext so it will hold a lot of data.
in make_status_failed we need to concatenate to the previous value and formate it like the suggestion above
Y-m-d H:i:s {status_code}: {error_message};

public function make_status_failed( int $id, string $error_code, string $error_message ) {

  • Replace "Bad Json"

  1. Replace "Bad Json" in get_queue_job_status by: "No message. Defaulted in get_queue_job_status"

    public function get_queue_job_status( $job_id, $queue_name, $is_home = false ) {

  2. Replace "Bad Json" in add_to_queue by: "No message. Defaulted in add_to_queue"

    public function add_to_queue( string $url, array $options ): array {

Estimate effort

Effort S

from wp-rocket.

MathieuLamiot avatar MathieuLamiot commented on July 24, 2024

Looks good, thanks.
Just an additional point for the concatenation in message:
make_status_failed is only called if retries >=3 in check_job_status. So in order to store messages for intermediary retires, we would need to add an else logic:

if ( $row_details->retries >= 3 ) {
				Logger::debug( 'RUCSS: Job failed 3 times for url: ' . $row_details->url );
				/**
				 * Unlock preload URL.
				 *
				 * @param string $url URL to unlock
				 */
				do_action( 'rocket_preload_unlock_url', $row_details->url );

				$this->used_css_query->make_status_failed( $id, strval( $job_details['code'] ), $job_details['message'] );

				return;
			}
else{
    $this->used_css_query->update_message($id, strval( $job_details['code'] ), $job_details['message'])
}

With update_message that is a new method that concatenates new data to the existing message.

from wp-rocket.

mostafa-hisham avatar mostafa-hisham commented on July 24, 2024

thanks, @MathieuLamiot I totally missed this one.
in that case, I suggest updating the message with the retries increment to cover the 408 cases too

$this->used_css_query->increment_retries( $id, $row_details->retries );

from wp-rocket.

MathieuLamiot avatar MathieuLamiot commented on July 24, 2024

Sounds good, either in the increment_retries method, or in a dedicated method next to it. 👍

from wp-rocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.