Issue live loading posts


(Sam Saffron) #1

Was browsing meta, and noticed a “loading” forever when a new post was added to a topic.

console says:

TypeError: Cannot read property 'get' of undefined
    at Discourse.PostStream.Em.Object.extend.storePost (https://d11a6trkgmumsb.cloudfront.net/assets/application-899429154a0b383e9cb39288f253d64c.js:7:19986)
    at Discourse.PostStream.Em.Object.extend.appendPost (https://d11a6trkgmumsb.cloudfront.net/assets/application-899429154a0b383e9cb39288f253d64c.js:7:18652)
    at https://d11a6trkgmumsb.cloudfront.net/assets/application-899429154a0b383e9cb39288f253d64c.js:7:17396
    at Array.forEach (native)
    at https://d11a6trkgmumsb.cloudfront.net/assets/application-899429154a0b383e9cb39288f253d64c.js:7:17374
    at m (https://d11a6trkgmumsb.cloudfront.net/assets/vendor-c93a4009213a86aa170d735da156f8d5.js:6:28992)
    at d (https://d11a6trkgmumsb.cloudfront.net/assets/vendor-c93a4009213a86aa170d735da156f8d5.js:6:28911)
    at _ (https://d11a6trkgmumsb.cloudfront.net/assets/vendor-c93a4009213a86aa170d735da156f8d5.js:6:29644)
    at https://d11a6trkgmumsb.cloudfront.net/assets/vendor-c93a4009213a86aa170d735da156f8d5.js:8:4902
    at Object.r.flush (https://d11a6trkgmumsb.cloudfront.net/assets/vendor-c93a4009213a86aa170d735da156f8d5.js:6:20315) vendor-c93a4009213a86aa170d735da156f8d5.js:5

cc @eviltrout


(Robin Ward) #2

I tried to reproduce this locally with no luck. Is there an easy repro case?


(Sam Saffron) #3

I think @codinghorror saw one of these earlier, maybe we should just make appendPost super robust and have it avoid appending any invalid state?


(Jeff Atwood) #4

Yep, here’s my report

TypeError: Cannot read property 'get' of undefined
    at Discourse.PostStream.Em.Object.extend.storePost (http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/applicati…fd1ac39d1e196032bc5f413bc.js?origin=http%3A%2F%2Fbbs.boingboing.net:8:4375)
    at Discourse.PostStream.Em.Object.extend.appendPost (http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/applicati…fd1ac39d1e196032bc5f413bc.js?origin=http%3A%2F%2Fbbs.boingboing.net:8:2294)
    at http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/applicati…ffd1ac39d1e196032bc5f413bc.js?origin=http%3A%2F%2Fbbs.boingboing.net:8:668
    at Array.forEach (native)
    at http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/applicati…ffd1ac39d1e196032bc5f413bc.js?origin=http%3A%2F%2Fbbs.boingboing.net:8:646
    at m (http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/vendor-07…d7a4a569ab47fc53357d52d9.js?origin=http%3A%2F%2Fbbs.boingboing.net:6:28974)
    at d (http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/vendor-07…d7a4a569ab47fc53357d52d9.js?origin=http%3A%2F%2Fbbs.boingboing.net:6:28893)
    at w (http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/vendor-07…d7a4a569ab47fc53357d52d9.js?origin=http%3A%2F%2Fbbs.boingboing.net:6:29623)
    at http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/vendor-07…9d7a4a569ab47fc53357d52d9.js?origin=http%3A%2F%2Fbbs.boingboing.net:8:4902
    at Object.n.flush (http://virtual-host-discourse.global.ssl.fastly.net/cdn_asset/bbs_boingboing_net/vendor-07…d7a4a569ab47fc53357d52d9.js?origin=http%3A%2F%2Fbbs.boingboing.net:6:20315) vendor-079af679d7a4a569ab47fc53357d52d9.js?origin=http%3A%2F%2Fbbs.boingboing.net:5

I do see this fairly regularly.

In this case, I was just idling on the topic near the bottom, and the above happened after the new reply came in.


(Robin Ward) #5

I’ve added a little robustness to the PostStream code:

Hopefully that helps!


(Jeff Atwood) #6

Looks like Robin found another case:

If you try to load a bunch of posts by ids at once but one of the posts does not exist for some reason, you get back undefined in an array. So operations on that undefined thing fail

The probable cause is a race condition. You request the post before it’s fully comitted to the DB

I imagine the message bus is pushing the id before the commit has finished

I added safety to make sure we don’t end up with undefined in the array. but at some point we should figure out why the message bus or whatever is sending posts before they are comitted


(Kane York) #8

Hey @eviltrout, here’s evidence that the message bus is, indeed, sending posts before they are committed:

  def create
    @topic = nil
    @post = nil
    Post.transaction do
      setup_topic
      setup_post
      rollback_if_host_spam_detected
      save_post
      extract_links
      store_unique_post_key
      consider_clearing_flags
      track_topic
      update_topic_stats
      update_user_counts
      create_embedded_topic
      
      ##############################
      publish     # <==== Publish on Message Bux
      ##############################
      ensure_in_allowed_users if guardian.is_staff?
      @post.advance_draft_sequence
      @post.save_reply_relationships
    end           # <==== Commit to Database

    ...

(Sam Saffron) #9

Let’s push publish to after the commit.


(Jeff Atwood) #10