Closed lanitochka17 closed 8 months ago
:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Triggered auto assignment to @deetergp (Engineering
), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Looking into this
⚠️ Looks like this issue was linked to a Deploy Blocker here
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.
If a regression has occurred and you are the assigned CM follow the instructions here.
If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.
The status is not sent to the backend in UTC format
we dont convert the clearAfter
Date to UTC before its sent to the backend
There is two ways here:
currentUserPersonalDetails
will always have the status as utc however the DRAFT status will be in local date because the draft status is not yet sent to the server so it shouldnt be parsed as UTC. with that being said the changes of the second solution should not introduce breaking change so lets dig into it:
first, when writing the data to the server we need to convert it into UTC format so we need to change the update function to:
function updateCustomStatus(status) {
const clearAfterInUtc = DateUtils.formatWithUTCTimeZone(status.clearAfter, 'yyyy-MM-dd HH:mm:ss');
const newStatus = {
text: status.text,
emojiCode: status.emojiCode,
clearAfter: clearAfterInUtc,
};
API.write('UpdateStatus', newStatus, {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: {
[currentUserAccountID]: {
status: newStatus,
},
},
},
],
});
}
then for the reading part, we need to add a new function inside the DateUtils file that converts the UTC string into a local date string given a certain format (this is the opposite of formatWithUTCTimeZone
)
so i have defined this funciton :
function formatUTCToLocal(dateString: string, dateFormat: string = CONST.DATE.FNS_FORMAT_STRING) {
if (dateString === '' || !dateString) {
return dateString;
}
const date = parse(dateString, dateFormat, new Date());
// Check if the date is valid
if (!isValid(date)) {
return '';
}
const utcDate = zonedTimeToUtc(date, 'UTC');
const localDate = zonedTimeToUtc(utcDate, timezone.selected);
// the timezone.selected is the timezone that the user selected at profile/timezone
return tzFormat(localDate, dateFormat, {timeZone: timezone.selected});
}
then we have two solutions:
status.clearAfter
data returned from the server to local time (this way is preferrable)to do so we need to add a new middleware to this folder: https://github.com/Expensify/App/blob/82b76c1a36cf1a01b00c14510a5812a591e7f2fd/src/libs/Middleware then we add the following middleware file:
then we need to add the new middleware to the index file, then we need to register it in the app file:
Request.use(Middleware.FormatClearAfterInPersonalDetails);
this will convert the value returned from the backend to a local date in the middle without the need to update the time in each component that uses it
like this:
const clearAfter = DateUtils.formatUTCToLocal(lodashGet(currentUserPersonalDetails, 'status.clearAfter', ''), 'yyyy-MM-dd HH:mm:ss');
@abzokhattab have you tested that? I don't think that is the correct cause. We don't need to set the status when we are just creating a draft, and when you actually click save it looks like the request is working properly.
When you refresh the page after your timer, the status disappears. That leads me to believe that the issue is that we are not pushing the updates to all users properly.
IMO this is not a blocker even though it is genuinely broken. The Status feature that we merged was massive, and reverting it is not feasible. I will work on a fix in web-e first thing next week
@stitesExpensify , I found out the comment wasn't working, so I hid it. After testing, I think the problem is related to time zones. I tried using a date from 6 hours ago, but the status was not cleared after that time had passed. However, when I checked it just now, the status was updated. It seems there's a mismatch in how the time zone is interpreted. I suspect the server, where the backend is running, is in the USA, causing the entered date to be parsed as a US date. This might be delaying the job trigger by a few hours.
My suggestion is to send the date from the frontend as UTC. This way, the backend can accurately parse and handle it. Additionally, it's worth noting that the backend doesn't have information about the client's timezone. The time string is sent to the backend without specifying the zone. In the provided data sample for updating the status, there is no information about the client's browser timezone:
To address this, two actions are recommended:
new Date()
in parsing the clearAfterTime value.Just tried to test it again .. this time the status is not cleared 😂 even after almost 11 hours of the custom date .. so i guess the backend doesnt clear it.
If we dont want to tackle the clearing process in the frontend we can prevent the status from being shown up in case the clearTime has passed.
If we have decided to tackle the status clearing process in the frontend, here is a blueprint for how we can achieve that :
inside the User.js file we need to add this function that would return the current status and (update it if the clear date has passed):
function getUserStatus(userPersonalDetails) {
const statusEmojiCode = lodashGet(userPersonalDetails, 'status.emojiCode', '');
const statusText = lodashGet(userPersonalDetails, 'status.text', '');
const statusClearAfter = lodashGet(userPersonalDetails, 'status.clearAfter', '');
if (statusClearAfter !== '' && new Date(statusClearAfter) < new Date()) {
if (userPersonalDetails.accountID === currentUserAccountID) {
clearCustomStatus();
clearDraftCustomStatus();
}
return {
emojiCode: '',
text: '',
clearAfter: '',
};
}
return {
emojiCode: statusEmojiCode,
text: statusText,
clearAfter: statusClearAfter,
};
}
then we need to replace this:
with:
const statusData = User.getUserStatus(currentUserPersonalDetails);
const currentUserEmojiCode = lodashGet(statusData, "emojiCode", "");
const currentUserStatusText = lodashGet(statusData, "text", "");
const currentUserClearAfter = lodashGet(statusData, "clearAfter", "");
same here:
change it to:
const status = User.getUserStatus(currentUserDetails);
const emojiCode = status.emojiCode;
and here change this:
to:
const { avatar, login, pendingFields, fallbackIcon } = personalDetails[actorAccountID] || {};
const status = User.getUserStatus(personalDetails[actorAccountID]);
and change this:
to:
const emojiStatus = User.getUserStatus(currentUserPersonalDetails).emojiCode;
and finally change this:
to
const statusData = User.getUserStatus(optionItem);
const emojiCode = lodashGet(statusData, "emojiCode", "");
const statusText = lodashGet(statusData, "text", "");
const statusClearAfterDate = lodashGet(statusData, "clearAfter", "");
OR
alternatively we can make the above change on connecting to the App so it will update status if needed as we currently do with the timezone
https://github.com/Expensify/App/assets/59809993/3f491858-e4d9-451d-aef5-82dcd9839054
Seems a backend issue where the status is not cleared after time expiration and the pusher event isn't receieved.
Seems a backend issue where the status is not cleared after time expiration and the pusher event isn't receieved.
I agree
I think there are actually 2 issues here. One is that we aren't sending the time to the server in UTC (frontend bug), and the second is that the user who set the status does not get a pusher notification (backend bug).
When the bedrock job gets created on the server, it uses local time so if you are west of UTC it runs instantly and clears your status, and if you are east of UTC it happens late.
Your status also disappears for other users, but not you.
Job added to Upwork: https://www.upwork.com/jobs/~013df2712d0a3d5327
Triggered auto assignment to @dylanexpensify (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 (External
)
Platforms
in OP are ✅)@abzokhattab the server always assumes the time is in UTC so the frontend fix here is sending the datetime as UTC from the frontend as you mentioned here https://github.com/Expensify/App/issues/33128#issuecomment-1858637283
This will not fully fix the bug, but it will help
Can you write a formal proposal for that solution please @abzokhattab ?
thank you!
@deetergp, @stitesExpensify, @abdulrahuman5196, @dylanexpensify Eep! 4 days overdue now. Issues have feelings too...
@abzokhattab Is the proposal ready as requested here? https://github.com/Expensify/App/issues/33128#issuecomment-1863353295
@stitesExpensify any idea how the BE handle the "clear after"? Does the BE process an empty emoji after or we just need to hide it on UI? I checked the Onyx values after the time of the clear period and it's not changed. I assume the BE is not doing any action!
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@deetergp @stitesExpensify @abdulrahuman5196 @dylanexpensify this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
Looking more into it today
@deetergp, @stitesExpensify, @abdulrahuman5196, @dylanexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
@deetergp, @stitesExpensify, @abdulrahuman5196, @dylanexpensify 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
Looking more into it today
@abzokhattab Gentle ping
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
This requires lots of changes so I added a blueprint for the changes in my proposal
Please have a look at the proposal idea and let me know if we can go with this direction .. if you confirm i can create a draft PR and you can have a look at the code changes
@abdulrahuman5196 to review ^! cc @deetergp
Reviewing now
@deetergp @stitesExpensify @abdulrahuman5196 @dylanexpensify this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!
@abzokhattab why do we need to convert in so many places? For things like getEndOfToday
and validateDateTimeIsAtLeastOneMinuteInFuture
can't we just use the local time for that, and then convert it right before we send it to the server?
I checked the Onyx values after the time of the clear period and it's not changed. I assume the BE is not doing any action!
@dragnoir Right, that's the first problem I mentioned here https://github.com/Expensify/App/issues/33128#issuecomment-1863349962
@abzokhattab to reply
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
@abzokhattab why do we need to convert in so many places? For things like getEndOfToday and validateDateTimeIsAtLeastOneMinuteInFuture can't we just use the local time for that, and then convert it right before we send it to the server?
I wanted to make the dateutil functions handle the conversion part themselves but this sounds like a lot of work and might cause breaking changes....
for that reason I am now considering the other way where we only change the clearAfter to UTC on update..
I have updated my proposal please have a look
@abdulrahuman5196 can you take a look at the newest proposal please?
@stitesExpensify updated the proposal to use a middleware instead of parsing the date into a local date on the component level
On looking @abzokhattab 's proposal here https://github.com/Expensify/App/issues/33128#issuecomment-1858139232 I don't see any strong RCA mentioned for the timezone issue, more it seems like a hypothesis.
Only on @stitesExpensify 's comment here it mentions some clear requirement from backend perspective that the frontend should provide the status date and time in UTC format.
@stitesExpensify Do we evaluate the proposal to just do the fix for One is that we aren't sending the time to the server in UTC (frontend bug)
or request to do more Root cause analysis on this issue?
@deetergp @stitesExpensify @abdulrahuman5196 @dylanexpensify this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:
Thanks!
Current assignee @abdulrahuman5196 is eligible for the Internal assigner, not assigning anyone new.
I don't see any strong RCA mentioned for the timezone issue, more it seems like a hypothesis.
don't get your comment can elaborate more ... The RCA is that we don't convert the clearAfter
to a UTC before it's sent to the backend it's rather sent in the client's local time not UTC.
Brandon mentioned that he will fix the original backend bug which is that the status is not cleared after the time has passed however he requested also that the date sent to the backend has to be in UTC
@abdulrahuman5196 to confirm above
Bump @abdulrahuman5196
Sorry for missing this out.
I don't see any strong RCA mentioned for the timezone issue, more it seems like a hypothesis.
don't get your comment can elaborate more ... The RCA is that we don't convert the
clearAfter
to a UTC before it's sent to the backend it's rather sent in the client's local time not UTC.Brandon mentioned that he will fix the original backend bug which is that the status is not cleared after the time has passed however he requested also that the date sent to the backend has to be in
UTC
@abzokhattab I understand your mention of we need to convert the time to UTC before sending it to the backend.
But why I mentioned it doesn't have strong RCA is because even if we did that, we can't verify if the change has fixed this issue or not without fixing the backend issues where the pusher notification is not sent as pointed out here - https://github.com/Expensify/App/issues/33128#issuecomment-1863349962
During my testing, I converted my timezone to UTC and tested, but the issue still persisted(I assume its due to push failure). The same would be happening at your testing as well, I assume that's why you had pointed out with the hypothesis here https://github.com/Expensify/App/issues/33128#issuecomment-1858637283.
So I wanted to confirm with @stitesExpensify on this requirement, since we won't be able to verify the fix if push notification is not sent? Correct me if wrong @stitesExpensify
Do we evaluate the proposal to just do the fix for
One is that we aren't sending the time to the server in UTC (frontend bug)
as pointed out here.
This should still be testable without fixing the backend issue. If you log in on one account in a normal tab and one account in an incognito tab, you will see the status expire correctly from the other user's point of view
Thanks for the info. Will check from other account
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 1.4.13-0 Reproducible in staging?: Y Reproducible in production?: N If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Applause - Internal Team Slack conversation:
Issue found when executing PR https://github.com/Expensify/App/pull/24620
Action Performed:
Precondition: user should be Signed In
Expected Result:
The status should be cleared when the clear timer has elapsed
Actual Result:
Please choose a time at least one minute ahead" error message is displayed, and the emoji status remains when the clear status timer has elapsed
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/Expensify/App/assets/78819774/7644a577-f91c-42b3-b93c-9b7b310f3e82
View all open jobs on GitHub
Upwork Automation - Do Not Edit