question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'tf' of undefined

See original GitHub issue

Hello, I am getting this error “Uncaught TypeError: Cannot read property ‘tf’ of undefined” in 0.7.2. (I was getting it in 0.5 as well, so upgraded, still getting it.)

It does not fail for every search; just some. I can’t figure out how to debug this or identify what is different between the search terms that work and the ones that don’t.

Note: I have a web site created by an now unavailable developer. I am hacking my way through trying to fix problems like this. I know just enough JS, etc, to be dangerous, but not enough to know what I am doing.

My browser reports the error on the tf = line here:

lunr.Index.prototype.documentVector = function (documentRef) {
  var documentTokens = this.documentStore.get(documentRef),
      documentTokensLength = documentTokens.length,
      documentVector = new lunr.Vector

  for (var i = 0; i < documentTokensLength; i++) {
    var token = documentTokens.elements[i],
        tf = this.tokenStore.get(token)[documentRef].tf,
        idf = this.idf(token)

    documentVector.insert(this.corpusTokens.indexOf(token), tf * idf)
  };

  return documentVector
}

It seems to be a something to do with this function. When I get the error, this function bails out at the if statement.

lunr.TokenStore.prototype.getNode = function (token) {
  if (!token) return {}

  var node = this.root

  for (var i = 0; i < token.length; i++) {
    if (!node[token.charAt(i)]) return {}

    node = node[token.charAt(i)]
  }

  return node
}

Any suggestions how I can debug this or fix it? Thank you. – Mike

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
ekryskicommented, Nov 2, 2017

I can confirm it’s definitely related to emoji’s. I removed them from our Gitbook and search is all good again.

0reactions
dafflcommented, Aug 16, 2018

We solved this using gitbook-plugin-advanced-emoji and replacing all emojis with their text representation from the emoji cheatsheet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue3 app with tensorflowjs throws TypeError: Cannot read ...
I've hit the same error in CLI without anything to do with Vue. In my case I've tried to use a tensor outside...
Read more >
Cannot read properties of undefined (reading 'backend') - TF.js
Hi everyone, I am experiencing the following error in my code: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ' ...
Read more >
Uncaught TypeError: Cannot read property '1' of undefined
This error occurs in Chrome Browser when you read a property or call a method on an undefined object . Uncaught TypeError: Cannot...
Read more >
Cannot read property 'texture' of undefined at tf.mul()
Each time I try to execute this code, an error "TypeError: Cannot read property 'texture' of undefined" occurs at "tf.mul()".
Read more >
uncaught typeerror: cannot read properties of undefined ...
That means either data.currentSong or data.currentArtist or both of them getting you undefined result. Answer to your question: There could be some differences ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found