NeilFraser / JS-Interpreter

A sandboxed JavaScript interpreter in JavaScript.
Apache License 2.0
2.01k stars 353 forks source link

Revert back to previous non-blocking state when stuck in a infinit loop #231

Closed ChrisAcrobat closed 2 years ago

ChrisAcrobat commented 2 years ago

I have a function in the interpreter which I call externally. If a call timeout I would like to revert the state to what it was before last call so I can call the function again with new set of data and keep the progress of the previous successful executions. Is there a way to do this today?

NeilFraser commented 2 years ago

Yes, you just need to serialize the state of the interpreter. That way you can restore to that state at any future time.

Serialization demo: https://neil.fraser.name/software/JS-Interpreter/demos/serialize.html

ChrisAcrobat commented 2 years ago

Great, thanks for the quick answer!