Giter VIP home page Giter VIP logo

Comments (4)

wanderer avatar wanderer commented on May 29, 2024

@Ryanmtate do you have the code that generates this error?

from merkle-patricia-tree.

tcoulter avatar tcoulter commented on May 29, 2024

I've seen this a bunch with the TestRPC. Was too intermittent to figure out the root cause however.

from merkle-patricia-tree.

erkmos avatar erkmos commented on May 29, 2024

This problem still exists with TestRPC, I've spent a few hours trying to track down how to fix it, but so far haven't figured out how. Callback hell...

I've tried making it pass an error in the callback from watchController.only in walkTrie helper processNode but there seems to be a lot of code elsewhere that doesn't follow the callback(error, value) convention, causing all kinds of strange behaviour. I squashed many of those, but I don't think calling the continuation in only with an error if node is undefined is the right fix. It seems to put the server's state manager in a broken state, all subsequent calls return the same error. Don't fully understand all the surrounding code yet.

Giving up for now, might look at it again later if I have time. But I'm documenting my findings below if anyone else has the patience:

The symptoms start with this line in Trie._findPath's processNode

walkController.only(branchIndex)

which then runs this function

only: function (childIndex) {
    var childRoot = node.getValue(childIndex)
    self._lookupNode(childRoot, function (node) { // node is undefined here
        var childKey = key.slice()
        childKey.push(childIndex)
        processNode(childRoot, node, childKey, cb)
    })
}

In the recursive call for processNode from above it calls this line

if (!node) return cb() <-- no arguments

this is cb from above

if (err) {
  return onDone(err)
}
// returnValues is an empty array from the walkTrie closure, so essentially onDone()
onDone.apply(null, returnValues) 

onDone from above is the callback in Trie.put at this line

self._findPath(key, function (err, foundValue, keyRemainder, stack) {
    // all arguments here are undefined because it gets called with no arguments
    if (err) {
        return cb(err);
    }
    // then update
    // this call crashes the program because stack is undefined
    self._updateNode(key, value, keyRemainder, stack, cb)
})

from merkle-patricia-tree.

holgerd77 avatar holgerd77 commented on May 29, 2024

Will cautiously close this since the issue is pretty old, there hasn't been any reports lately and the code base changed significantly since. There has also been a refactor of the WalkController in #135 by @jochem-brouwer. Feel free to reopen though if you still think this is an issue.

from merkle-patricia-tree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.