ether/ep_comments_page

BUG: Error when viewing Pad with comments - sometimes

tiblu opened this issue · 0 comments

tiblu commented

Reproduce

  • Add a comment
  • Refresh the page with cache enabled

Result

SOMETIMES I get an error:

VM110:726 Uncaught TypeError: Cannot read property 'data' of undefined
    at HTMLSpanElement.eval (eval at _compileFunction (require-kernel.js?v=c6e36b0f:226), <anonymous>:726:15)
    at Function.each (ace2_common.js?callback=require.define&v=c6e36b0f:750)
    at jQuery.fn.init.each (ace2_common.js?callback=require.define&v=c6e36b0f:543)
    at EpComments.localizeExistingComments (eval at _compileFunction (require-kernel.js?v=c6e36b0f:226), <anonymous>:713:15)
    at Object.eval (eval at _compileFunction (require-kernel.js?v=c6e36b0f:226), <anonymous>:111:10)
    at Object.trigger (html10n.js?v=c6e36b0f:106)
    at html10n.js?v=c6e36b0f:716
    at html10n.js?v=c6e36b0f:955
    at each (html10n.js?v=c6e36b0f:745)
    at Loader.window.html10n.Loader.load (html10n.js?v=c6e36b0f:1

image

Observations

  • Happens sometimes, ONLY when cache is ENABLED
  • It seems at when localizeExistingComments runs, the commentId is set, BUT this.comments is empty.

Causes?

  • Probably race condition as the localization and getComments race each other. If getComments wins, the error occurs.

Possible fixes?

  • Check that this.comments array has the comment like collectComments does. Do nothing if it does not exist. It adds no extra problems as there is an interval to check and localize comments.
  • Call this.collectComments(); in localizeExistingComments.