Plugin registration


  • Plugin & Theme Dev

    How to troubleshoot plugin loading?
    After restarting of NodeBB, none of available plugins do not load anymore.

    Also, Reload give such error in console:

    18/4 18:32 [34370] - error: TypeError: Reduce of empty array with no initial value
        at Array.reduce (native)
        at async.waterfall.x (/Users/nicolas/Documents/Works/JavaScript/NodeBB/src/plugins.js:343:8)
        at fn (/Users/nicolas/Documents/Works/JavaScript/NodeBB/node_modules/async/lib/async.js:641:34)
        at Immediate._onImmediate (/Users/nicolas/Documents/Works/JavaScript/NodeBB/node_modules/async/lib/async.js:557:34)
        at processImmediate [as _immediateCallback] (timers.js:358:17)
    TypeError: Reduce of empty array with no initial value
        at Array.reduce (native)
        at async.waterfall.x (/Users/nicolas/Documents/Works/JavaScript/NodeBB/src/plugins.js:343:8)
        at fn (/Users/nicolas/Documents/Works/JavaScript/NodeBB/node_modules/async/lib/async.js:641:34)
        at Immediate._onImmediate (/Users/nicolas/Documents/Works/JavaScript/NodeBB/node_modules/async/lib/async.js:557:34)
        at processImmediate [as _immediateCallback] (timers.js:358:17)
    

    Branch: 0.6.x


  • Plugin & Theme Dev

    Solved by just reloading everything - several times: Database, NodeBB


  • Staff Admin

    That error is caused by the following bit of code in src/plugins.js

    paths = paths.map(function(pluginLib) {
    	var parent = path.dirname(pluginLib);
    	return cached.filter(function(libPath) {
    		return libPath.indexOf(parent) !== -1;
    	});
    }).reduce(function(prev, cur) {
    	return prev.concat(cur);
    });
    

    If paths is an empty array calling reduce will throw that error. We should add better checks to detect that.


Log in to reply
 

Suggested Topics

| |