AmyrAhmady / samp-node

a SA-MP plugin to run nodejs scripts
71 stars 8 forks source link

Calling samp.removeEventListener from within an event crashes the server #12

Closed ElDuderino420 closed 2 years ago

ElDuderino420 commented 3 years ago

For some reason when I try to remove an event during a separate event trigger, the server crashes. It will crash regardless if any function references are provided.

//will crash server
samp.on('OnPlayerConnect', function(playerid) {
    samp.removeEventListener('OnPlayerSpawn');
});
//works as intended
samp.on('OnPlayerConnect', function(playerid) {
    console.log('onplayerconnect')
});

samp.removeEventListener('OnPlayerSpawn');
AmyrAhmady commented 3 years ago

Right now most of functionalities inside of an event listener's scope requires making your Promise handler, or when you are having an uncaught exception in there, otherwise you will receive a crash cause of bad thread management I have (basically none) in samp-node, this will be fixed in future but right now I am busy with another project. I'll return to this soon, so you can either wait or if you are capable of contributing, you can help :)

AmyrAhmady commented 2 years ago

Probably fixed by #15 , if it still happens, please report it again by creating a new issue

plutalov commented 2 years ago

Probably fixed by #15 , if it still happens, please report it again by creating a new issue

Still crashes. I'm gonna fix it along with the NodeJS upgrade to v16

AmyrAhmady commented 2 years ago

Fixed by this https://github.com/AmyrAhmady/samp-node/commit/3961a068decac080ebe26f29140c69dc2e314d97