asvd / jailed

execute untrusted code with custom permissions
MIT License
1.01k stars 69 forks source link

The process never exits. #38

Open rezaalavi opened 8 years ago

rezaalavi commented 8 years ago

Hi,

I am having this issue with jailed under node that the process never exist therefore onDisconnect never gets called. This happens even with the sample code provided on github.

Here the code that I used:

var jailed = require('jailed' )
var code = `
    var api = {
        square: function(num, cb) {  
            cb(num*num);
        }
    }
    application.setInterface(api);
`

var plugin = new jailed.DynamicPlugin(code);
var start = function() {

    plugin.remote.square(2, reportResult);
}
var reportResult = function(result) {
    console.log("Result is: " + result);  
}
plugin.whenConnected(start);

Executing the above under node never exist and only shows "Result is: 4"

asvd commented 8 years ago

The plugin is designed to be used multiple times and does not shut down by itself. You should explicitly disconnect it using the disconnect() method either form the application, or from inside the plugin.

Let me know if you think that this behaviour can be redone in a more convenient way.