morungos/wordnet

Missing data on nested calls

Closed this issue · 0 comments

Reported today. I can replicate this easily, and it's nasty. We need to fix this ASAP.

Hope you don't mind me emailing you with a question about your wordnet library. I'm working on a project that uses wordnet, and I'm trying to use your library for part of it, but I'm running into a problem with returning results in callbacks. I'm also not that familiar with Promises so I'm trying to use the async methods but getting the same issues. I'm not experienced enough as a developer to know if I'm doing something wrong or if it might be a bug.

So for example, when I run this code:

wordnet.lookup("node", function(nodeResults) {
  console.log("node " + nodeResults.length);
  wordnet.lookup("test", function(testResults){
    console.log("test " + testResults.length);
  });
});

I get:
node 8
test 0

And I get the same thing when I run this:

wordnet.lookupAsync("node").then(function(nodeResults) {
  return wordnet.lookupAsync("test").then(function(testResults){
    return [nodeResults, testResults];
  });
}).then(function(allResults){
  console.log("node " + allResults[0].length);
  console.log("test " + allResults[1].length);
}).catch(function(error){
  console.log(error);
});

Do you happen to know why I wouldn't get any results for "test"?

Thought maybe there was something obvious I'm missing. If you have time to look at it I would really appreciate it.