Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onmessage function is not being called, causing timeout when defined. #37

Open
ijonas opened this issue Nov 1, 2014 · 1 comment
Open

Comments

@ijonas
Copy link

ijonas commented Nov 1, 2014

Hi,

I've been playing with Sandbox on node 0.10.33 on OSX. I can send message from inside the Sandbox out the host environment. When I try and postMessage() into the Sandbox and with an onmessage function defined, the run() method times out.

Here's my code

var Sandbox = require('sandbox');

sb = new Sandbox();
sb.on('message', function (message) { 
  console.log("outer message handler: "+message); 
});
sb.on('ready', function() { 
  console.log('ready. posting...'); 
  sb.postMessage("calling when ready"); 
});
sb.run("postMessage('message from inside'); 10 + 10;", function(output) { 
  console.log(output) 
});



sb = new Sandbox();
sb.on('message', function (message) { 
  console.log("outer message handler: "+message); 
});
sb.on('ready', function() { 
  console.log('ready. posting...'); 
  sb.postMessage("calling when ready"); 
});
sb.run("onmessage = function (msg) { console.log(msg); };", function(output) { 
  console.log(output) 
});

Producing the following output:

outer message handler: message from inside
ready. posting...
{ result: '20', console: [] }
ready. posting...
{ result: 'TimeoutError', console: [] }    

Is anyone else seeing this problem? I've run the test code and it passes on my machine. If I modify the test code by removing the spies, then the same timeout problem occurs.

A little help appreciated,
Ijonas.

@yoavprat
Copy link

yoavprat commented Feb 7, 2016

Same for me, when running the example getting this TimeoutError (OS X as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants