Bug breaks left/right hotkeys

I believe this is a bug in LingQ’s rendering logic which causes hotkeys to stop responding.

When reading a lesson using the left and right keyboard hotkeys, sometimes I hit a word that causes this error to appear on DevTools console, and the left and right hotkeys stop responding. It is reliably triggered by that same word. I can refresh the browser window to fix the hotkeys, but as soon as I highlight that word again, the error happens again, and hotkeys are broken.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'index')
    at main-329afa4cfc6efd30fd22.js:2:5103749

The relevant line of code, in context, is: (this is from DevTools’ prettified view of the minified JS)

            }, {
                key: "renderRelatedPhrases",
                value: function(t, a, n) {
                    var i = this
                      , o = t.map((function(e) {
                        var t = e.normalizedTerm;
                        return (0,
                        r.termWords)(t)
                    }
                    )).map((function(e) {
                        var t = i.postings.relatedPhraseLocation(e, a, n).index; // <-- this is the line that throws the error
                        return {
                            start: t,
                            end: t + e.length - 1
                        }
                    }
                    ))
2 Likes

Thanks, we will look into it.

1 Like

@zoran I hit this again today. Has there been any movement here? Is there anything I can share to make this issue easier to debug?

1 Like

@zoran this bug can be avoided by disabling renderRelatedPhrasesHighlight in ReadingPane, can that be implemented as a fix?

There’s a logic bug where the code generates a related phrase that doesn’t exist anywhere, then tries to get the location of it so it can be highlighted. This causes the bug which permanently breaks hotkeys until the page is reloaded.

You could even add a try-catch around this rendering logic so that you don’t even need to fix the underlying logic bug. Just catch the error and skip related phrase highlighting, and continue to do everything else so that hotkeys don’t break.

1 Like

I reported this to our development team. I’ll let you know as soon as I hear back or have any update.

1 Like