freefoote / node-red-flows-mongo

2 stars 4 forks source link

Error loading flows: TypeError: undefined is not a function #2

Open dnoliver opened 8 years ago

dnoliver commented 8 years ago

Hello, I am trying to install this module in my node red server, and I am having the following error

4 Jul 12:28:38 - [warn] Error loading flows: TypeError: undefined is not a function

TypeError: undefined is not a function
    at Object.module.exports.parseConfig (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red\red\runtime\nodes\flows\util.js:52:16)
    at setConfig (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red\red\runtime\nodes\flows\index.js:89:34)
    at C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red\red\runtime\nodes\flows\index.js:72:20
    at tryCatchReject (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:845:30)
    at runContinuation1 (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:804:4)
    at Fulfilled.when (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:592:4)
    at Pending.run (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:483:13)
    at Scheduler._drain (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\Scheduler.js:62:19)
    at Scheduler.drain (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\Scheduler.js:27:9)
    at process._tickCallback (node.js:355:11)
Potentially unhandled rejection [2] TypeError: Cannot read property 'missingTypes' of null
    at start (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red\red\runtime\nodes\flows\index.js:209:25)
    at tryCatchReject (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:845:30)
    at runContinuation1 (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:804:4)
    at Fulfilled.when (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:592:4)
    at Pending.run (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\makePromise.js:483:13)
    at Scheduler._drain (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\Scheduler.js:62:19)
    at Scheduler.drain (C:\Users\dnoliver\git\simple-node-red-server\node_modules\node-red-flows-mongo\node_modules\when\lib\Scheduler.js:27:9)
    at process._tickCallback (node.js:355:11)

My env:

"node-red": "^0.14.3", $ node --version v0.12.7 Windows 8.1 64bits My mongo db was created with mLab https://mlab.com/

masalinas commented 7 years ago

I have the same error like you using the last version of node-red 0.14.4. If you debug some code of the node-red runtime and the Storage API implementation you'll see that:

The first time that you start node-red the runtime expect that exist any flow collection, so when it tries to parse the flow collection, don't find anyone and send this error, however the system create an initial settings in the mongodb under storages with a default flow collection, so if you restart again node-red the error is not send now.

When you use the default Storage API implementation (local file system) node-red create always a default flow collection before this parse method is started, so the system don't send any error, but when you use this implementation node-red don't create this default flow collection before and the system crash,

I'll investigate why??