Tell HN: My Hacker News app (HACK) is sort of broken this afternoon
As of this afternoon, I received lots of emails reporting a bug in the app where:
1. Tapping on a story was taking to the link for the story instead of the comments. There was no way to access the comments.
2. All stories showed "now" as the time posted instead of the correct time.
3. Threads didn't display the title for the parent post.
This occurred due to Hacker News making some changes to its website's HTML today.
Since the Hacker News API is pretty much useless (it's a read only API and doesn't allow voting, favoriting, commenting etc. Also very hard to work with), my app relies on the website which it parses to get the content. It does the parsing using XPath. Due to the changes in the HTML, the XPath in the app were no longer valid.
I have already submitted an update to Apple and the Play Store for fixing this bug. Hoping to have it approved soon (hopefully sometime tonight/tomorrow).
I am really sorry about the inconvenience to all the users who rely on my app.
The apps are:
https://apps.apple.com/ca/app/hack-for-hacker-news-reader/id1464477788
https://play.google.com/store/apps/details?id=com.pranapps.hack
Feel free to ask questions. Thanks.
31 comments
[ 2.8 ms ] story [ 80.9 ms ] threadThe better way I am thinking is to fetch the XPath/CSS query selection strings remotely on each app launch. Since fixes for the website changes usually involve me only having to modify the XPath for each element in my app, I could just modify the XPath on my server and then have my app fetch them on app launch. The XPath is just a string in the app, so it can be done.
Whether this is doable obviously depends upon how big of a change the HN website HTML has. I will look into it.
If the logic needs to change more substantially yeah you’re gonna have to ship an app change.
How much slower are we talking? 20ms vs 9ms? I feel like we developers prematurely optimize critical paths without taking the actual timeliness of the objective into account.
When using the app, the more the number of comments a post has, the longer it takes. On older devices (iPhone 6S or cheaper Android phones for example), it can take 10-15 seconds to parse 500 comment posts. My app already has to take this into account and therefore only displays 20 comments right away and then adds additional comments as it's finishing parsing the rest.
Since the app has a "go to next top level comment thread" button, this button has to stay hidden until all 500 comments have been parsed. So any slowness in the parsing can significantly ruin the experience.
https://news.ycombinator.com/item?id=32978099
Not sure if it is an HN API change or not, but feels like it.
0. https://github.com/plibither8/refined-hacker-news
https://github.com/plibither8/refined-hacker-news/issues/121
> "The v0 API is essentially a dump of our in-memory data structures. We know, what works great locally in memory isn't so hot over the network. Many of the awkward things are just the way HN works internally. Want to know the total number of comments on an article? Traverse the tree and count. Want to know the children of an item? Load the item and get their IDs, then load them. The newest page? Starts at item maxid and walks backward, keeping only the top level stories. Same for Ask, Show, etc. I'm not saying this to defend it - It's not the ideal public API, but it's the one we could release in the time we had. While awkward, it's possible to implement most of HN using it."
https://github.com/HackerNews/API
If one wants to get the comments for a post on HN from the API, they have to first fetch the post, then fetch every single comment of the post 1 by 1. So if the post has 500 comments, one has to basically send over 500 network requests......
They did say that they plan on released a better API in the future. However, as far as I know, it will be read only initially. So won't be much useful for my app.
Thanks a lot for the app btw, pretty much one of the very few I use daily and actually cannot think of much in terms of complaints. Speed and the feel of non-slugishness is actually the main pro that no other HN app I saw do as well. Not sure if it is really significantly faster or just a perception due to animations done well, but it works lol.
Looks like about 3 hours ago, Hacker News changed some HTML again.....no idea why they are doing that.
Fixed it. Already submitted the update to Apple and Google again. Hoping to have it approved soon.
I am really sorry about this inconvenience.
@dang is it possible to keep track of these changes? Or be notified of upcoming changes?
Please give it a try and let me know if you have questions. The update version should be v86.86. If it's not visible yet on the app store, please give it an hour or so for it to become available.
Here's a direct link:
https://apps.apple.com/ca/app/hack-for-hacker-news-reader/id...
This should solve the bugs related to the HN news website changes.
Thanks a ton for the quick update.
Depending on available resources of course, you could run regular checks of the xpath validity, with a mapping of of other identifiers, you could use those others to see the new xpath, auto update the code, call a script to compile and republish.
Thats an ugly way but doable.
Another would be to have a remote mapping, so when you open the app, you get the 'latest' mappings. This way you can still run your 'is_this_xpath_valid' and if not update the xml/json whatever. When the app opens, it downloads the latest version and continues on.
I say that option rather than a remote API because of sheer request load possible is wild, whereas a simple file is cheap.
If you're rich, have your cron/checker run a bit more regularly then and api that, like a cache checks each request, you can have it running in a passive lambda for example (not sure best way to optimize that one).
My long story short is, try to remove the dependency on the services you're consuming. In this case it's a weird one but if you want any help, you're not open source so dm, I love this stuff.