Open joejoe04 opened 10 months ago
Well, there isn't a proper way to reproduce the issue, however, we could hard code a string in $job_details['code']
here https://github.com/wp-media/wp-rocket/blob/2b2243e08aecf0d7618179106c2a133749762e47/inc/Engine/Optimization/RUCSS/Strategy/Strategies/DefaultProcess.php#L108
This would ensure to get the same error as reported.
The issue is that a string
is given in the update_message
method while it's waiting for an int
.
To solve the issue we could force the cast of$job_details['code']
to an int
. So in case this is a string
with an actual number it would output its int
version otherwise it would return 0
.
To do that, we can modify this line by :
$this->used_css_query->update_message( $row_details->id, (int) $job_details['code'], $job_details['message'], $row_details->error_message );
S
No
I think we shouldn't bail-out, we still want the process to fully execute. But we could instead make sure that if we receive a string, we either convert it to the corresponding int value (if it's a string representing a number), or add a 0
value.
I've modified the grooming accordingly to the feedback from @Tabrisrp
LGTM
If it helps we are running into this exact issue right now.
We can dig out any details that might help with your fix.
Thanks, Martin
https://wp-media.slack.com/archives/C43T1AYMQ/p1712848710899159 Example of what is passed as argument in the stack trace. This is indeed linked to cUrl errors.
Added to cooldown sprint as it is blocking this: https://github.com/wp-media/wp-rocket-lighthouse-simulator/issues/36
Reproduce the problem
Well, there isn't a proper way to reproduce the issue, however, we could hard code a string in
$job_details['code']
hereThis would ensure to get the same error as reported.
Identify the root cause
The issue is that a
string
is given in theupdate_message
method while it's waiting for anint
.Scope a solution
To solve the issue we could force the cast of
$job_details['code']
to anint
. So in case this is astring
with an actual number it would output itsint
version otherwise it would return0
. To do that, we can modify this line by :$this->used_css_query->update_message( $row_details->id, (int) $job_details['code'], $job_details['message'], $row_details->error_message );
Effort estimation:
S
Is a refactor needed in that part of the codebase?
No
@Miraeld To reproduce the issue you can try to set a really low timeout from what I remember it worked as it was returning an empty string instead of an int for the status code.
You can also check the respond structure to have an example to add inside your tests.
@CrochetFeve0251 , yes but in local we don't send anything to the SaaS, so if someone is trying to reproduce in a local environment, I think the solution I gave is kinda the easiest.
However on a real environment, (staging or production), in fact, the low timeout should get the same output, a string which will cause an issue.
another case here: https://secure.helpscout.net/conversation/2660678910/504266?folderId=273761
And another case here: https://secure.helpscout.net/conversation/2660678910/504266/
Describe the bug group.one was having infrastructure issues with services like Imagify, RocketCDN and RUCSS which led to slowdowns and random server errors.
It seems in the case of Remove Unused CSS, it caused these errors to be logged for some:
Expected behavior We should protect against these errors in cases where similar server/infrastructure issues might happen again in the future.
Additional context https://wp-media.slack.com/archives/CAFHCKKNV/p1705502738733959 https://wp-media.slack.com/archives/C43T1AYMQ/p1705526400628139 https://secure.helpscout.net/conversation/2483200195/469576/ https://secure.helpscout.net/conversation/2483200980/469577/
Acceptance Criteria (for WP Media team use only)