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

Any way to run asynchronously? #13

Open
alexdovzhanyn opened this issue Feb 10, 2018 · 2 comments
Open

Any way to run asynchronously? #13

alexdovzhanyn opened this issue Feb 10, 2018 · 2 comments

Comments

@alexdovzhanyn
Copy link

I'm currently looking at trying to use this library to add javascript as a contracting language to the UltraDark Blockchain, and I've gotten it to fit quite nicely!

The one thing I'm worried about is having someone write an infinite loop as part of their contract, because this would essentially lock all nodes that receive the contract. I was thinking of having each node validate the contract by running all the functions defined in the javascript, and if any of the functions take longer than 30 seconds to return, just kill the transaction.

There are is an issue with my approach (that I was hoping you could help solve):
When running an infinite loop within a separate process, I can't kill the Execjs process by doing Process.exit(pid, :reason). This returns true, but running ps aux | grep execjs reveals that the process is still running. I'm not sure of any other good alternative to testing against infinite loops without disabling a looping mechanism altogether. Any suggestions would be very greatly appreciated!

@vans163
Copy link

vans163 commented Jun 22, 2018

Probably needs a simple patch to bootstrap the js process launcher. I remember doing this before.. also Raik did this afaik.. its more complex then it seems, but it like involves a shell script being held open and BEAM opens the port to hold it. When elixir proc dies, port closes, shell script gets STDOUT closed, then shell script is responsible to kill the JS proc (shell script obv launches JS proc in nonblocking way).

Cool project BTW.

@alexdovzhanyn
Copy link
Author

Thanks! I'll have to check out how they do this and implement it. Currently the process blocks until javascript processing is completed so thats not ideal

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