Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated lazy loading #1735

Closed
MinatureCookie opened this issue Nov 3, 2013 · 24 comments
Closed

Repeated lazy loading #1735

MinatureCookie opened this issue Nov 3, 2013 · 24 comments

Comments

@MinatureCookie
Copy link

The lazy loader is repeatedly loading, even when the page is just sat in the background doing nothing (i.e. there are no changes to push)

A quick look at webkit dev-tools looks like something's .onreadystatechange method is being triggered once per second, sending a POST to https://habitrpg.com/api/v1/user/batch-update?_v=*******&data=*************

This results in the loading bar just spinning away at the top, jumping around, but never disappearing. Not to mention the wasted network usage! :(

@gwillen
Copy link

gwillen commented Nov 3, 2013

I'm seeing this also, and I've seen it before, too. It's sending about a request per second.

This is what it keeps sending (updating v each time):

Request URL:https://beta.habitrpg.com/api/v1/user/batch-update?_v=47267&data=1383512588151
Request Method:POST
Status Code:200 OK

Request headers:
Accept:application/json, text/plain, /
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:56
Content-Type:application/json;charset=UTF-8
Cookie:
Host:beta.habitrpg.com
Origin:https://beta.habitrpg.com
Referer:https://beta.habitrpg.com/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
x-api-key
x-api-user:2bb01217-3fc8-4a87-9e89-f4e4ae7acc53

Request payload:
[{op:set, data:{preferences.timezoneOffset:480}}]

Response headers:
Access-Control-Allow-Headers:Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key
Access-Control-Allow-Methods:OPTIONS,GET,POST,PUT,HEAD,DELETE
Access-Control-Allow-Origin:https://beta.habitrpg.com
Connection:keep-alive
Content-Length:12
Content-Type:application/json; charset=utf-8
Date:Sun, 03 Nov 2013 21:03:08 GMT
Vary:Accept-Encoding
X-Powered-By:Express

Response payload:
{"_v":47269}

lefnire added a commit that referenced this issue Nov 4, 2013
@lefnire
Copy link
Contributor

lefnire commented Nov 4, 2013

oh god! thanks @gwillen for that detail, it really helped me narrow down the issue. I just pushed a commit. Can y'all see if this fixed the issue for you?

lefnire added a commit that referenced this issue Nov 4, 2013
@gwillen
Copy link

gwillen commented Nov 4, 2013

I was just about to say that I didn't know what triggered the issue. But I bet I do. Could it have been triggered by the DST change? And when I saw it before could it have been triggered by a system timezone change?

(Asking because without knowing what triggered it, and having only seen it a few times, it would be hard to test if it was fixed.)

@lefnire
Copy link
Contributor

lefnire commented Nov 4, 2013

yeah, it will definitely be triggered by timezone change. But more likely, as part of the challenges feature, we did a big overhaul on the backend, adding stricter requirements to the user schema. part of these requirements comes type-checking on attributes. Looks like timezone was being stored as a string for some people ("480" instead of 480) and being detected as "changed". the weird thing is, I'd assume this infinite-loop bug would only get triggered once, and only once, for each user - ever - since the server would then save the new value, and the next refresh would come with the server's data. weird that y'all experienced it multiple times :/ anyway, is it working then?

@gwillen
Copy link

gwillen commented Nov 4, 2013

Well, it's not doing it now, and changing my system timezone doesn't trigger it. So it's as fixed as I can tell. :-)

@lefnire
Copy link
Contributor

lefnire commented Nov 4, 2013

kk. yeah, should be fixed - I tried mucking around manually and it's good. Thanks for pointing this out. The crazy thing is this bug should have been happening for many months now - since the angular rewrite; I'm surprised it wasn't caught sooner! Anyway, thanks!

@lefnire lefnire closed this as completed Nov 4, 2013
@MinatureCookie
Copy link
Author

Actually, sorry - on my end this has now gotten a lot WORSE, rather than resolved!

It's now sending off the event every fraction of a second. This is what's being sent on my end

Request URL: https://habitrpg.com/api/v1/user/batch-update?_v=170531&data=1383550732223
(v increments by 2 each time, so 170531, 170533, 170535...)
Request Method: POST
Request Status: 200

Request Headers:
POST /api/v1/user/batch-update?_v=170531&data=1383550732223 HTTP/1.1
Host: habitrpg.com
Connection: keep-alive
Content-Length: 54
Accept: application/json, text/plain, /
Origin: https://habitrpg.com
x-api-user: ***
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
x-api-key: ***
Content-Type: application/json;charset=UTF-8
Referer: https://habitrpg.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,en-GB;q=0.6
Cookie: connect.sess=s%3Aj%3A%7B%22passport%22%3A%7B%7D%2C%22userId%22%3A%22aa6dfcb4-86a2-41a1-993c-5ea9e34e399c%22%7D.y%2B81%2FIqb%2FDJMe0EsETjUstTv2%2BwyNrgcZYEHJLwyrc0; __utma=122018834.657894833.1383550651.1383550651.1383550651.1; __utmb=122018834.2.10.1383550651; __utmc=122018834; __utmz=122018834.1383550651.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)

Response Headers:
HTTP/1.1 200 OK
Access-Control-Allow-Headers: Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key
Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,HEAD,DELETE
Access-Control-Allow-Origin: https://habitrpg.com
Content-Type: application/json; charset=utf-8
Date: Mon, 04 Nov 2013 07:38:53 GMT
Vary: Accept-Encoding
X-Powered-By: Express
Content-Length: 13
Connection: keep-alive

Response Payload:
{_v: 170533}

@lefnire
Copy link
Contributor

lefnire commented Nov 4, 2013

@MinatureCookie does yours have a "Request Payload" like @gwillen's did? That [{op:set, data:{preferences.timezoneOffset:480}}] really helped me narrow down the issue. Have you tried a hard refresh?

@MinatureCookie
Copy link
Author

I tried clearing all history (cache etc. included) on Chrome, then reloading. No dice.

Sorry I forgot to include the request payload! Here's another request...

Request URL: https://habitrpg.com/api/v1/user/batch-update?_v=172425&data=1383551522357
Request Method: POST
Status Code: 200 OK

Request Headers:
Accept:application/json, text/plain, /
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,en-GB;q=0.6
Connection:keep-alive
Content-Length:54
Content-Type:application/json;charset=UTF-8
Cookie:connect.sess=s%3Aj%3A%7B%22passport%22%3A%7B%7D%2C%22userId%22%3A%22aa6dfcb4-86a2-41a1-993c-5ea9e34e399c%22%7D.y%2B81%2FIqb%2FDJMe0EsETjUstTv2%2BwyNrgcZYEHJLwyrc0; __utma=122018834.657894833.1383550651.1383550651.1383550651.1; __utmb=122018834.3.10.1383550651; __utmc=122018834; __utmz=122018834.1383550651.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Host:habitrpg.com
Origin:https://habitrpg.com
Referer:https://habitrpg.com/
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
x-api-key:***
x-api-user:***

Request Payload:
[{op:set, data:{preferences.timezoneOffset:0}}]

Response Headers:
Access-Control-Allow-Headers:Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key
Access-Control-Allow-Methods:OPTIONS,GET,POST,PUT,HEAD,DELETE
Access-Control-Allow-Origin:https://habitrpg.com
Connection:keep-alive
Content-Length:13
Content-Type:application/json; charset=utf-8
Date:Mon, 04 Nov 2013 07:52:03 GMT
Vary:Accept-Encoding
X-Powered-By:Express

I checked a few other requests, looks like timezoneOffset is always set as 0

@lefnire
Copy link
Contributor

lefnire commented Nov 4, 2013

Crap! Exact same issue / path then.... so weird it's not getting updated in the browser for you. I even tried loading your account locally and all was fine. I'm gonna hit the sack now, sorry to leave your account like this right now - I'll tackle this moment I can this week though.

@lefnire lefnire reopened this Nov 4, 2013
@MinatureCookie
Copy link
Author

That's fine. I'll try experimenting around a little bit, see if I can get it to start/stop at all...

@BlackEdder
Copy link
Contributor

I still have the spinning loading icon and the progress bar is always there. When I open the (beta) site in opera I can clearly see the page constantly being redrawn.

Request URL: https://beta.habitrpg.com/api/v1/user/batch-update?_v=615796&data=1383555698276
Request Method: POST
Status Code: HTTP/1.1 200 OK
Request Headers 09:01:38.000
x-api-user: 62cf3b41-a297-4dd9-aa2d-2d1e051abbde
x-api-key: ****
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20131025 Firefox/24.0
Referer: https://beta.habitrpg.com/
Pragma: no-cache
Host: beta.habitrpg.com
Content-Type: application/json;charset=utf-8
Content-Length: 54
Connection: keep-alive
Cache-Control: no-cache
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: application/json, text/plain, /
Sent Cookie
tour_end: yes
tour_current_step: 0
connect.sess: s:j:{"passport":{},"userId":"****"}.****
__utmz: 122018834.1373019618.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
__utmc: 122018834
__utmb: 122018834.4.10.1383555101
__utma: 122018834.1558137625.1373019618.1383316473.1383555101.240
__qca: P0-364477270-1380014797579
__atuvc: 18|41,13|42,11|43,9|44,3|45
Response Headers Δ206ms
X-Powered-By: Express
Vary: Accept-Encoding
Date: Mon, 04 Nov 2013 09:01:38 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 13
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,HEAD,DELETE
Access-Control-Allow-Headers: Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key

@BlackEdder
Copy link
Contributor

The response payload is also
_v: ....

Strangely enough it looks like the number increases with two everytime.

@lefnire
Copy link
Contributor

lefnire commented Nov 4, 2013

FWIW, this won't have been a new problem. It's just that we added an loading indicator for http requests, so now you can see there's a problem - this has probably been going on for months :/

@BlackEdder
Copy link
Contributor

Habitrpg used to work fine in opera, but does keep reloading now (for me). I am not sure if these two things are related, but that would suggest it is a new problem.

@MinatureCookie
Copy link
Author

Okay - I changed my timezone to Pacific (US) time, and that fixed the problem. Even having changed it back to UK time now, the problem remains fixed...

Which is great for me personally, but I can't help diagnose the problem at all now...

Is it possible that your fix would have needed a local timezone change, or possibly just a day change (the timezone change brought me back to Sunday, then forwards to Monday), to kickstart it into working on any account with the problem?

EDIT:
Although HabitRPG seems to still think it's Sunday at the moment, despite it being Monday... (Sunday dailies are active). I'm not sure if that's related at all

EDIT2:
Ah, no - opening a fresh browser instance (i.e. a browser I've never used HabitRPG on before) still yields the bug. Weirdly, wiping browser history entirely on Chrome doesn't cause the bug to restart - everything is still fine on Chrome.

@BlackEdder
Copy link
Contributor

Changing timezone also fixed it for me both in firefox and opera, but the problem happened again as soon as I switched back to European time.

@lefnire
Copy link
Contributor

lefnire commented Nov 4, 2013

can y'all try now? I did some peaking around and user._v was sometimes NaN in the database. I don't know how this happened, and certainly don't now how it popped up only recently. I did db.users.update({_v:NaN},{$set:{_v:1}},{multi:1}) to bypass that, and I'm going to be digging into code to see where that could have come from

@MinatureCookie
Copy link
Author

I still seem to be getting it on a fresh browser! :(

Does it not replicate for you if you change your local timezone to UK, and then clear all browser history?

@BlackEdder
Copy link
Contributor

I am still getting it as well.

EDIT: I am also in the UK by the way.

@tzolking
Copy link

tzolking commented Nov 5, 2013

Having the same problem over at my account. In Firefox, IE and at Android APP.
User id is: ea1901e5-bdac-4417-8655-88748df202f1

@joss-c
Copy link

joss-c commented Nov 14, 2013

I'm having this issue in both Firefox and Chrome. It's kind of annoying lol

@lefnire
Copy link
Contributor

lefnire commented Nov 15, 2013

fixed

@lefnire lefnire closed this as completed Nov 15, 2013
@tzolking
Copy link

Problem fixed, no further issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants