HabitRPG / habitica

A habit tracker app which treats your goals like a Role Playing Game.
https://habitica.com
Other
11.99k stars 4.09k forks source link

Cron did not run (no quest progress, no damage from incomplete Dailies, Dailies still checked from yesterday) [$270 awarded] #1057

Closed impr closed 9 years ago

impr commented 11 years ago

When I logged in this morning my dailies from yesterday were still showing as checked. I tried reopening habitrpg, I tried logging out and logging back in, and I tried waiting (it's been an hour now). No luck, my dailies still show as checked even though I haven't gotten out of bed yet today...

I do have two dailies which I was not supposed to do yesterday (MWF dailies) and they are now showing as tickable so my account clearly knows that it is Monday. Maybe this is just the site's way of telling me those are the only dailies I should do today and I should take the day off from everything else...


edit by admin:

If you experienced some effects of cron but not all of them, then you actually were hit by this bug: https://github.com/HabitRPG/habitrpg/issues/4313 (for example, if some of your Dailies became unticked but not all of them, or if you took Damage from your Dailies even though they remained ticked, or if your Party page shows a quest message for you from overnight).

What to do if your Dailies are still ticked from yesterday:

Go to the Tavern to see if you are Resting in the Inn. If the left-hand column has a large green button that says "Check Out of the Inn", click that, and your Dailies will reset tomorrow (more information about Resting in the Inn). If you didn't see that button, then either wait until tomorrow because your Dailies will almost certainly reset correctly tonight, or:

  1. Record your current values for HP (health), XP (experience), GP (gold), and MP (mana).
  2. Untick all your Dailies.
  3. Go to Settings -> Site and use Fix Character Values to put your values back to the correct settings.
  4. For each Daily, edit it and go into the Advanced Settings to increase the streak count by one.

The $270 bounty on this issue has been claimed at Bountysource.

paglias commented 10 years ago

@lefnire here https://github.com/HabitRPG/habitrpg-shared/blob/master/script/helpers.coffee#L23 when using startOf why don't we use moment().zone()? I'm not sure that passing o.now to moment() takes the timezone offset into consideration https://github.com/HabitRPG/habitrpg-shared/blob/master/script/helpers.coffee#L23

Also, always in the same method (startOfDay) we pass the not-sanitized dayStart from options not from o.

static24 commented 10 years ago

Browser: Chrome UUID: 6dca820b-a82b-4726-8d55-6b638145d830

I've been having issues with dailies resetting. I have my day start set to 4am, and for some reason the dailies just don't reset sometimes. I often check dailies between midnight and 4am, and this is only maybe the third time this has happened, so I am not sure what is causing it exactly.

meganstrickland commented 10 years ago

Well, I checked my dailies at 1:45am last night / this morning, and my dailies appear to have reset correctly---yay! (I also lost HP as expected for unchecked dailies.) Did someone fix something?

onlysal commented 10 years ago

Well, I got home late last night so checked my dailies (my end of day is 3 a.m.) after midnight. Today they're still checked. So mine isn't fixed. Sigh.   Sally B. Sedgwick sbsedgwick@yahoo.com

On Thursday, November 21, 2013 2:15 PM, meganstrickland notifications@github.com wrote:

Well, I checked my dailies at 1:45am last night / this morning, and my dailies appear to have reset correctly---yay! (I also lost HP as expected for unchecked dailies.) Did someone fix something? — Reply to this email directly or view it on GitHub.

mojganin commented 10 years ago

Yesterday, encountered a new wrinkle. Checked one of my dailies before midnight, got XP and gold. After midnight, logged on to check off the other, and as soon as the page loaded up, I got XP and gold again for the daily I had previously marked as completed, as though I pressed it again. Although now, bringing up the site again, it seems to have actually reset this morning. So, yesterday's sequence seems to have been: pre-midnight, mark daily and get credit; midnight, get double credit for daily; end-of-day, clear and reset dailies.

peppervl commented 10 years ago

I'm having this issue as well. My custom reset time is 4:00. I went in after midnight last night (but before 4:00 AM) and then today (again after midnight but before 4:00 AM) I go to check them off and they're all grey.

I have had this happen a few times before, though this is the first time I've reported it. I do believe that I'd started checking things off after midnight the day before those times as well.

laisan commented 10 years ago

The same happening with me. I have my reset time at 7 am. Couple of days ago it noticed that that setting has been reset to 00:00. I set it back to 7:00 - and now my dailies are not resetting.

lefnire commented 10 years ago

@paglias Your comments shed a lot of light, I think you've found the problem. It looks like the issue is

Another possibility is it's bailing early for some reason, maybe here. Looking at that code, (a) we've stopped using user.lastCron = 'new' for new users, (b) I'm not showing any null lastCrons in the database, (c) does that even make sense for timezone changes? I'm thinking, maybe we can just delete this code block and see what happens?

Sorry, I should know this stuff better - my mind represses dayStart code after I've "fixed" it... it's my least favorite component of HabitRPG.

I know it sucks, but it sounds like the temporary solution for everyone is to just set custom day start back to 0:00 - lesser of two evils until we can get the main evil vanquished

Question for everyone - has this ever happened when switching timezones? Or is it just standard usage / same location

laisan commented 10 years ago

same location

wc8 commented 10 years ago

In case it helps users in the meantime, my manual new day method is to write down stats, uncheck Dailies & go to Settings>Restore to correct stats e-g. (gold, health).

lefnire commented 10 years ago

@paglias

@lefnire here https://github.com/HabitRPG/habitrpg-shared/blob/master/script/helpers.coffee#L23 when using startOf why don't we use moment().zone()? I'm not sure that passing o.now to moment() takes the timezone offset into consideration https://github.com/HabitRPG/habitrpg-shared/blob/master/script/helpers.coffee#L23

We manually add timezoneOffset here, for every date-calculation. Because we're running cron on the server, not the client, moment.zone will give us the server's tz. So what we do is set user.preferences.timezoneOffset here to the client's tz from the browser (or mobile app), then we use that to manually calculate tz on the server so that moment.zone doesn't use the server's tz.

The math may be incorrect, so if you see a flaw...

Also, always in the same method (startOfDay) we pass the not-sanitized dayStart from options not from o.

A bug! Good eye! I pushed the fix at https://github.com/HabitRPG/habitrpg-shared/commit/bf7f7b65836ee590b407399855a60dc381fb9142 . Let's see if that solves any issues. However, I don't think it will, because TMK this would have only been an issue for non-sanitized dayStarts (undefined, NaN, strings, etc) - which we fixed up in that recent migration & UserSchema.pre('save'). I'm gonna keep poking around, and let's hope that was surprisingly the solution.

lefnire commented 10 years ago

Woo, I think I got it! https://github.com/HabitRPG/habitrpg-shared/commit/282e105ea3c318b6128277318a073af6f9fa20a8#diff-cfb682379d1261ba2ad825d0f77b43e0L364

paglias commented 10 years ago

@lefnire I'll give it a try this evening, but this should happen only when user moves to another timezone? Because to me it happened and I never moved since I use habit

lefnire commented 10 years ago

@paglias well, the code I commented out here was indeed meant to handle the edge-case of switching timezones. However, if moment(user.lastCron).isAfter(now) doesn't take user.preferences.timezoneOffset into account - so I think it was actually the bug. I think user.lastCron is always "after now" for users with timezones greater than 280 (server tz), so it was exiting early and setting user.lastCron = now.

The solution should be something like if moment(user.lastCron).zone(user.preferences.timezoneOffset).isAfter(now). However, I'm still not sure this is the correct way to handle the timezone-switching edge-case. In fact, I think it might be handled properly automatically since the browser sets the user timezone on initial load. So instead of fixing that code-block, I just removed it for now and we can revisit. (tz-switching is pretty rare anyway)

lefnire commented 10 years ago

Has this resolved for anyone?

onlysal commented 10 years ago

Nope. - Had to check them at 12:15 a.m. (one of those days) yesterday. My start is 3 a.m.  They are still checked this morning....   Sally B. Sedgwick sbsedgwick@yahoo.com

On Wednesday, December 4, 2013 11:21 AM, Tyler Renelle notifications@github.com wrote:

Has this resolved for anyone? — Reply to this email directly or view it on GitHub.

onlysal commented 10 years ago

What's interesting is that when this feature was first introduced it worked beautifully.... Just saying...   Sally B. Sedgwick sbsedgwick@yahoo.com

On , S B Sedgwick sbsedgwick@yahoo.com wrote:

Nope. - Had to check them at 12:15 a.m. (one of those days) yesterday. My start is 3 a.m.  They are still checked this morning....   Sally B. Sedgwick sbsedgwick@yahoo.com

On Wednesday, December 4, 2013 11:21 AM, Tyler Renelle notifications@github.com wrote:

Has this resolved for anyone? — Reply to this email directly or view it on GitHub.

lefnire commented 10 years ago

What's interesting is that when this feature was first introduced it worked beautifully.... Just saying...

Well, that was when cron was being calculated on the client instead of the server. We had to move it to the server to support the mobile app, a necessary move but which added extra complexities. sigh ok, back to the drawing board

laisan commented 10 years ago

Looks that it works fine for me now. I first changed reset time to 00:00, and it didn't work. Then (a day later) I changed it back to 7:00 and now it's working and unchecks dailies at that time. At least for the last couple of days.

monkeyik commented 10 years ago

same issue here. stuff is still grayed out and its well after midnight. this looked like it would help a lot and be very motivating but, obviously only if it works like it should

jimcullenaus commented 10 years ago

I'm still having this issue. I have it set to reset at 05:00 in my timezone (UTC+10, although I recently moved to UTC+7). My dailies seem to always last two days before resetting. i.e., I'll tick them off before going to bed, when I wake up they're still ticked. However, the following day, it does usually reset.

I'll try what @DoWhatYouMust said, though. Maybe that will help.

lefnire commented 10 years ago

FYI, the solution for everyone is to use 0 for the custom day start. We'll work on fixing that feature

jimcullenaus commented 10 years ago

Hmm interesting. @DoWhatYouMust's idea solved it for me.

deilann commented 10 years ago

Can you tag this with the relevant tags so it's easier to find?

wc8 commented 10 years ago

This just affected my party member. He didn’t sign in until this evening. No custom day start—he hasn’t changed it. No resting in tavern.

dfjkla commented 10 years ago

Happens still to me, I have custom day start.

lefnire commented 10 years ago

@dfjkla what's your UUID? I wanna check something. Also, use CDS at your own risk, it's very finicky - as mentioned in this thread, users experiencing issues should set it to 0

As people experience this issue going forward, post your UUID. I have a more robust error-reporter these days, and I want to cross-check this issue against any errors. It could be that cron is failing completely due to a thrown error, rather than due to timezone issues

meganstrickland commented 10 years ago

@lefnire So should we go back to using the custom day start feature? Or should we still leave it set to 0? I haven't had the issue since I set it to 0, but it would be really nice to be able to use this feature if it is working again. :o)

(User ID 73e5125c-2c87-4004-8ccd-972aeac4f17a)

lefnire commented 10 years ago

I'd say leave it at 0, since we haven't done anything to fix it yet (and I don't want to screw up your days). A couple people have reported experiencing this issue even without CDS, very few though. Could be they actually had errors triggered, and the rest of y'all are just experiencing the heart of this ticket which appears to be timezone miscalculations. So yea, keep your CDS to 0 until we fix it, but then report your UUID if you experience the issue again.

FWIW I plan to work on a "Manual Day Start" feature in the near future. If the setting is enabled, cron isn't run automatically - you have to click a button "run cron", which will (1) enable recording yesterday's activity, but (2) double as a pseudo-CDS feature, safeguarding those who want CDS but experience this bug. You can see the conversation leading to that here.

colegleason commented 10 years ago

@lefnire When you have time, could you walk me through how the cron workflow works? For example: what TZ is the main server, etc.

I'm just trying to get my local setup to be as close as possible to make sure I can reproduce this faithfully.

laisan commented 10 years ago

I'm still experiencing this problem - both with custom day start and day start at 0. It just happens from time to time.

User ID -

08c918fb-f22e-4c40-9eb1-a6e74a04643f

On Wed, Jan 8, 2014 at 11:28 AM, Cole Gleason notifications@github.comwrote:

@lefnire https://github.com/lefnire When you have time, could you walk me through how the cron workflow works? For example: what TZ is the main server, etc.

I'm just trying to get my local setup to be as close as possible to make sure I can reproduce this faithfully.

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/1057#issuecomment-31810736 .

colegleason commented 10 years ago

How to reproduce:

  1. First, you cannot reproduce the bug using the following steps between the hours of 12AM and 1AM. So if that is the current time, change your system clock.
  2. Go onto your local HabitRPG and set CDS to be sometime in the future. Then, check off some dailies.
  3. Using mongo, issue the commands below. This ensures your lastCron is before what we will set the Custom Day Start (CDS) to. The times should be lastCron < Current Hour < Current Time < Custom Day Start

    d = new Date()
    d.setHours(d.getHours()-1)
    db.users.update({_id:"UUID HERE"}, {$set:{"lastCron": d}})
  4. Now go onto your local HabitRPG and change your CDS to be the current hour such that lastCron < Current Hour == Custom Day Start < Current Time.
  5. Refresh. Expected: Cron runs, dailies reset. Actual: Cron does not run. Dailies are still checked.
colegleason commented 10 years ago

Trying the above reproduction steps with colegleason/habitrpg-shared 3bd81abda39 results in the expected behavior. I think this is the fix for dailies not resetting (maybe not other semi-related issues).

lefnire commented 10 years ago

@colegleason let's give this a shot. I stepped through the code it and looks good to me, and testing 24h cycles is much smarter than 1d increments, :+1:. Anyone experiencing this issue, keep an eye on it and report back if you could

colegleason commented 10 years ago

@lefnire We should revisit that cronMatrix code to do more rigorous testing based on times. I don't think it would be crazy to step through a bunch of different permutations of hours since last cron, etc.

colegleason commented 10 years ago

Note that to experience the issue again, you would have to have Custom Day Start set and log on in between midnight and your Custom Day Start. If anyone is willing to risk their dailies not being reset for another day, please help us test this!

On Thu, Jan 9, 2014 at 11:57 AM, Tyler Renelle notifications@github.comwrote:

@colegleason https://github.com/colegleason let's give this a shot. I stepped through the code it and looks good to me, and testing 24h cycles is much smarter than 1d increments, [image: :+1:]. Anyone experiencing this issue, keep an eye on it and report back if you could

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/1057#issuecomment-31958841 .

Cole Gleason

Student, University of Illinois at Urbana-Champaign Email: cg@colegleason.com Website: colegleason.com

lefnire commented 10 years ago

And if you're willing, I can manually set your day back if this fails, so don't be afraid. I'm gonna try to test it too

meganstrickland commented 10 years ago

@colegleason @lefnire I would be happy to test! I'm on Pacific Time (UTC-8) so it will be several hours before I can do it, but I would be delighted to help in any small way I can.

wc8 commented 10 years ago

Is this testing just for users with a local HabitRPG setup?

colegleason commented 10 years ago

@wc8 Nope, @lefnire is pushing this live.

Another note: This bug does not affect you if your lastCron is sometime before midnight, so reports might still be a little intermittent. @lefnire, you could probably edge people's lastCron (after midnight, before CDS) up a bit to test in the DB, although I'm not sure you'd want to do that.

onlysal commented 10 years ago

OK, will do it tonight. Haven't dared since I set to 0 and then reset to a custom day. I don't need to do anything else, right?   Sally B. Sedgwick sbsedgwick@yahoo.com

On Thursday, January 9, 2014 1:29 PM, Cole Gleason notifications@github.com wrote:

Note that to experience the issue again, you would have to have Custom Day Start set and log on in between midnight and your Custom Day Start. If anyone is willing to risk their dailies not being reset for another day, please help us test this!

On Thu, Jan 9, 2014 at 11:57 AM, Tyler Renelle notifications@github.comwrote:

@colegleason https://github.com/colegleason let's give this a shot. I stepped through the code it and looks good to me, and testing 24h cycles is much smarter than 1d increments, [image: :+1:]. Anyone experiencing this issue, keep an eye on it and report back if you could

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/1057#issuecomment-31958841 .

Cole Gleason

Student, University of Illinois at Urbana-Champaign Email: cg@colegleason.com Website: colegleason.com — Reply to this email directly or view it on GitHub.

meganstrickland commented 10 years ago

I just tried setting my CDS to 5, and then went on my merry way and hatched a zombie wolf, which I believe caused a refresh... and it appears that my day ticked over immediately, even though it is not past midnight or my CDS. I took a big HP hit (because I had yet to check most of my dailies) and all of my dailies are now unchecked and habits reset to yellow. Oddly, not all of my streaks were reset.

UID 73e5125c-2c87-4004-8ccd-972aeac4f17a

colegleason commented 10 years ago

@meganstrickland If your lastCron had fallen between midnight and your CDS the previous day, moving it forward would trigger it.

colegleason commented 10 years ago

(Which probably has the potential for abuse.)

meganstrickland commented 10 years ago

@colegleason I'm afraid I'm out of my depth here---I don't even know what "lastCron" is---but if this is the way the feature will work going forward, it should probably have some explanatory text because it is not expected behavior for the un-savvy (like me). To be clear, I am not complaining that this happened to me---I knew it was a test. Just saying that it should be explained going forward if this is how it's going to work. :-)

meganstrickland commented 10 years ago

@colegleason @lefnire Should I proceed with checking off dailies as per usual? For testing purposes, does it matter if I do that before midnight or between midnight and CDS? Should I do some of both?

colegleason commented 10 years ago

Sorry about getting all technical! I've been staring at this bugs for days now and it's starting to get to me :wink:

Yeah, go ahead. If your day already reset it shouldn't matter.

On Thu, Jan 9, 2014 at 11:07 PM, meganstrickland notifications@github.comwrote:

@colegleason https://github.com/colegleason @lefnirehttps://github.com/lefnireShould I proceed with checking off dailies as per usual? For testing purposes, does it matter if I do that before midnight or between midnight and CDS? Should I do some of both?

— Reply to this email directly or view it on GitHubhttps://github.com/HabitRPG/habitrpg/issues/1057#issuecomment-32003073 .

Cole Gleason

Student, University of Illinois at Urbana-Champaign Email: cg@colegleason.com Website: colegleason.com

meganstrickland commented 10 years ago

@colegleason No worries! I am extremely grateful that you have been staring at this bug! I will take notes about my stats before midnight, between midnight and CDS, and tomorrow morning after CDS, and report back. Thank you so much for working on this!

onlysal commented 10 years ago

Yeah! - did mine after midnight (on the app) last night (start is at 3) and just checked (on computer) and they reset just fine... (Yes, I'm on Eastern time - but it certainly hasn't been working here either....)

Sally B-   Sally B. Sedgwick sbsedgwick@yahoo.com

On Friday, January 10, 2014 1:46 AM, meganstrickland notifications@github.com wrote:

@colegleason No worries! I am extremely grateful that you have been staring at this bug! I will take notes about my stats before midnight, between midnight and CDS, and tomorrow morning after CDS, and report back. Thank you so much for working on this! — Reply to this email directly or view it on GitHub.

meganstrickland commented 10 years ago

Knock on wood, but I think that it's working! I took note of my stats before midnight, then refreshed and noted my stats and checked some more dailies between midnight at CDS, and refreshed today after CDS. So far, everything is behaving as expected. Yay!