Open cracker0dks opened 4 years ago
What are you trying to do? What should the expected outcome be?
I was calling a function, but by mistake I called it with "null" so I got the deadlock (No error, nothing). So I traced it back and made a bugreport on the node repo... they say it's not a node problem.
Which function? Please post some code/example so we can reproduce this.
there is not more code than I posted on the nodejs issue: If have this function:
var test = function (obj) {
obj.getId();
}
and I call it like this:
dc.on('DC_EVENT_INCOMING_MSG', () => {
test(null)
})
ofc I didn't called it this way on purpose when I noticed it... :)
@cracker0dks It would be really useful if you could post a code snippet that can reproduce the problem, i.e. a minimal example that can be run by e.g. node index.js
.
const DeltaChat = require('deltachat-node');
const dc = new DeltaChat();
var test = function (obj) {
obj.getId();
}
dc.on('ALL', function(code, msg, msg1) {
if(msg1.indexOf("INBOX-fetch started")!==-1) { //Just wait till dc checks the inbox
console.log("Deltacore locks after this line below <<<")
test(null)
}
console.log("ALL", code, msg, msg1)
})
dc.open(() => {
const onReady = () => {
console.log("DeltaChat Core is ready!");
setInterval(function() {
console.log("YO!") //Interval to check if node is running (And it is!)
}, 5000)
}
if (!dc.isConfigured()) {
dc.once('ready', onReady)
dc.configure({addr:"email", mail_pw : "password"})
} else {
onReady()
}
});
console.log("START DC!")
Ok, here you go. Paste this into a test.js (change user and pw) and run it. Dc will get a hard locked on "Inbox check". Nodejs will be still running but no more output from dc and no erros
const DeltaChat = require('.').default
const dc = new DeltaChat()
const opts = {
addr: '[email]',
mail_pw: '[addr]'
}
const contact = '[email2]'
async function main() {
const dc = new DeltaChat()
dc.on('ALL', function(code, msg, msg1) {
throw new Error('test')
console.log("ALL", code, msg, msg1)
})
await dc.open('./')
try {
await dc.configure(opts)
console.log('a')
} catch (err) {
console.error("Failed to configure because of: ", err)
dc.close()
return
}
dc.startIO()
console.log('fully configured')
dc.stopIO()
console.log('stopped io')
dc.close()
}
main()
Seems to look like that weird things happen if we throw an error inside a js method called from the c stuff
Hey, at first I thought this was a node bug and opened an issue there... but they say it probably on DC side... so what do you think?
https://github.com/nodejs/help/issues/2357
cheers