tern icon indicating copy to clipboard operation
tern copied to clipboard

analyzeAll: `c` (callback) is undefined

Open datamadsen opened this issue 12 years ago • 2 comments

I have been having problems with a couple of node modules lately - specifically bcrypt and mongoose.

I have run tern from my project library (node node_modules/tern/bin/tern --verbose), which revealed that a callback function, passed as argument to analyzeAll, is undefined on line 331 in lib/tern.js.

The line looks like this: if (done) c();. The stacktrace looks like this:

/Users/tmadsen/projects/tern/node-bug/node_modules/tern/lib/tern.js:331
    if (done) c();
              ^
TypeError: undefined is not a function
    at analyzeAll (/Users/tmadsen/projects/tern/node-bug/node_modules/tern/lib/tern.js:331:15)
    at Object.done (/Users/tmadsen/projects/tern/node-bug/node_modules/tern/lib/tern.js:295:7)
    at Object.signal (/Users/tmadsen/projects/tern/node-bug/node_modules/tern/lib/signal.js:19:58)
    at Object.signal.mixin.finishAsyncAction (/Users/tmadsen/projects/tern/node-bug/node_modules/tern/lib/tern.js:164:37)
    at /Users/tmadsen/projects/tern/node-bug/node_modules/tern/lib/tern.js:247:13
    at fs.js:266:14
    at Object.oncomplete (fs.js:107:15)

No completions is returned after this error happens - not even for string types.

I changed the line (331) to: if (done && c) c(); and then it works. However - I have no idea what implications this might have on the rest of tern's functionality, so I haven't attached a pull request here. Please let me know if you'd like me to.

My .tern-project looks like this:

{
    "plugins": {
        "node": {}
    }
}

The file, where I'm reproducing the bug consistently looks like:

var mongoose = require('mongoose');
mongoose.

or:

var bcrypt = require('bcrypt');
bcrypt.

datamadsen avatar Jun 07 '14 05:06 datamadsen

Attached patch should fix this. And since it is pretty major, I put out a new release that includes the fix.

marijnh avatar Jun 08 '14 20:06 marijnh

Thanks so much.

datamadsen avatar Jun 10 '14 08:06 datamadsen