At approximately 1 AM, 1 Jan 2024 (Malaysia Time GMT+8), I noticed that the homescreen widget not showing the information properly.
Some person also reporting the same thing on Facebook
It just show the template data, which indicates that it has the prayer time data. But somehow cannot display them.
Chronology
I started investigating the issue related to the homescreen widget. Upon reading the logcat, I understand that the app is loading the data for December 2023.
After spending few hours looking at widget, I moved my focus to the api: https:://api.waktusolat.app. I immediately noticed that the requested year is not the same as response year.
Below is reenactment of the issue:
At this time, I was super sleepy eepy. I quickly looked at the source code for the endpoint and noticed that the response year the API is returning is not from the query. It is from the Date function apparently. So quick fix before going to bed, I just pass the query year to the response year. Like bypassing the Date function. Not thinking any issues that could happened.
After waking up for Subuh. my email flooded with reports for error:
Now, checking the API response, I found out that the year property that we quick fix before, returns a string instead of a integer. Duh..
I'm out of home when checking and attempt to solve this isssue. I did not bring laptop or tablet, so I have to resort to my phone. The
struggle is real. As a quick fix, I just changed the type from string to number by using Number function. Problem solved.
Understanding the issue
Now we understand the root issue for this messes is coming from bad API response data. To recall, here is the problem started:
I immediately noticed that the requested year is not the same as response year.
Below is reenactment of the issue:
What caused this behavior at the first place? Well, is the Date function!
We (Malaysia) are at GMT +8 zone, while the server that this API is served is somewhere not in Malaysia. So, the API returns the year that country. So, when the system wanted to determine its current year, it returns the different year from Malaysia.
Mitigation Strategy
Enforce that the Date function from the API use Asia/Kuala_Lumpur timezone.
Favors year that is passed to the query ?year=2024 than determine the current year.
Below is the example:
Conclusion
No longer have the aforementioned error.
The widget also working now
I'm lucky I can remediate this issue immediately because it only happened on the server side. If it were happened on client side, I will need everyone to update the app once it's published.
Overview
At approximately 1 AM, 1 Jan 2024 (Malaysia Time GMT+8), I noticed that the homescreen widget not showing the information properly.
Some person also reporting the same thing on Facebook
It just show the template data, which indicates that it has the prayer time data. But somehow cannot display them.
Chronology
I started investigating the issue related to the homescreen widget. Upon reading the logcat, I understand that the app is loading the data for December 2023.
After spending few hours looking at widget, I moved my focus to the api: https:://api.waktusolat.app. I immediately noticed that the requested
year
is not the same as responseyear
.Below is reenactment of the issue:
At this time, I was super sleepy eepy. I quickly looked at the source code for the endpoint and noticed that the response
year
the API is returning is not from the query. It is from theDate
function apparently. So quick fix before going to bed, I just pass the queryyear
to the responseyear
. Like bypassing theDate
function. Not thinking any issues that could happened.After waking up for Subuh. my email flooded with reports for error:
The error may look similar to https://github.com/mptwaktusolat/app_waktu_solat_malaysia/issues/23#issuecomment-723678770 and some others.
Now, checking the API response, I found out that the
year
property that we quick fix before, returns a string instead of a integer. Duh..I'm out of home when checking and attempt to solve this isssue. I did not bring laptop or tablet, so I have to resort to my phone. The struggle is real. As a quick fix, I just changed the type from string to number by using
Number
function. Problem solved.Understanding the issue
Now we understand the root issue for this messes is coming from bad API response data. To recall, here is the problem started:
What caused this behavior at the first place? Well, is the
Date
function!We (Malaysia) are at GMT +8 zone, while the server that this API is served is somewhere not in Malaysia. So, the API returns the year that country. So, when the system wanted to determine its current year, it returns the different year from Malaysia.
Mitigation Strategy
Date
function from the API useAsia/Kuala_Lumpur
timezone.?year=2024
than determine the current year.Below is the example:
Conclusion
No longer have the aforementioned error.
The widget also working now
I'm lucky I can remediate this issue immediately because it only happened on the server side. If it were happened on client side, I will need everyone to update the app once it's published.