Closed ekkis closed 7 years ago
ok, to remove the issue of promises I've tested this in a simpler way:
var neo = require('neo4j');
var db = new new.GraphDatabase(...);
and a call with invalid cypher still blows up without returning an error:
db.cypher('invalid cypher script', (err, res) => {
if (err) console.log('ERROR: ' + err);
console.log(res);
})
help?
this is making me crazy. here's a complete test. save the file as "q":
#!/usr/bin/env node
const url = 'http://neo4j:MyPass@localhost:7474';
const Neo4j = require('neo4j');
const db = new Neo4j.GraphDatabase(url);
try {
db.cypher({query: process.argv[2]}, function(err, ls) {
console.log('--- CALLBACK ---');
if (err) {
console.log('--- ERROR ---');
console.log(err);
}
console.log('--- RESULT ---');
console.log(ls);
});
}
catch (e) {
console.log('--- CAUGHT ---');
console.log(e);
}
so if I run at the command line:
q "match (n:test) return n"
I get back what I would expect:
--- CALLBACK --- --- RESULT --- [ { n: Node { _id: 0, labels: [Object], properties: [Object] } } ]
but I miss-type the command:
q "match (n:test))) return n"
I see:
/Users/ekkis/Development/x/inc/node_modules/neo4j/lib-new/errors.js:20 Error.captureStackTrace(this, this.constructor); ^
TypeError: Error.captureStackTrace is not a function at ClientError.Error [as constructor] (/Users/ekkis/Development/x/inc/node_modules/neo4j/lib-new/errors.js:20:13) at new ClientError (/Users/ekkis/Development/x/inc/node_modules/neo4j/lib-new/errors.js:81:48) at Function.__dirname.Error.Error._fromObject (/Users/ekkis/Development/x/inc/node_modules/neo4j/lib-new/errors.js:70:14) at /Users/ekkis/Development/x/inc/node_modules/neo4j/lib-new/GraphDatabase.js:302:25 at Request._callback (/Users/ekkis/Development/x/inc/node_modules/neo4j/lib-new/GraphDatabase.js:92:20) at Request.self.callback (/Users/ekkis/Development/x/inc/node_modules/request/request.js:187:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request.
(/Users/ekkis/Development/x/inc/node_modules/request/request.js:1048:10) at emitOne (events.js:96:13)
not even the try/catch works! what??
ok, with the help of jfhbrook from freenode's #node.js I've "fixed" this issue. the library remains broken but for those who care, the exceptions can be caught like this:
process.on('uncaughtException', function(e) {
console.log('--- CAUGHT BY EVENT ---');
console.log(e);
});
Thanks for the TON of hours of time and frustration you put into looking into this! That "fix" worked for me too to keep the server from crashing completely.
How can we return some value for the API? As catching the unhandled exception works, but unable to return a custom error or text
I use bluebird with this library:
but when I issue a request that fails, the code fails to catch it:
and instead I get a crash like this:
I'm using node v7.3.0 and can't help but thinking it must be related to: https://github.com/thingdom/node-neo4j/issues/211
I need to stop crashing every time the cypher send is malformed. can anyone help?