-
Notifications
You must be signed in to change notification settings - Fork 148
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
Need best practices guides for performance and memory usage #101
Comments
I can't stress this enough. I'm trying to integrate this into my project, and I'd like to safely add usage and resource limits. What areas I'm struggling with:
If I wrap this in a using block, it will output:
and then dispose of the engine If I execute this, and add a |
Hi @danbopes,
We generally recommend that applications stay away from Originally this API was somewhat suitable for sandboxing, but the V8 team decided years ago that constrained script execution isn't a goal for V8. Today, exceeding any of the specified limits causes V8 to crash instantly, and that's by design. The API might still be useful for expanding V8's default limits, but we've found that V8 can then hit other limits that are inaccessible and vary unpredictably from version to version. ClearScript does offer support for "soft limits" (see The bottom line is that, unfortunately, if you must run untrusted script code with 100% safety, you'll need a Chromium-like multi-process architecture. The V8 team equates executing untrusted script code with invoking a function in an untrusted DLL. V8's API is constantly changing though, and we'll continue to watch for new developments.
For these purposes you can use
There's no special API for that, but you can always wait for a pre-arranged completion signal: engine.AddHostType("Console", typeof(Console));
engine.AddHostType("api", typeof(TestApi));
engine.Script.done = new ManualResetEventSlim();
engine.Execute(@"
Console.WriteLine('start');
const main = async () => {
Console.WriteLine('main');
var res = await api.delay('end');
Console.WriteLine(res);
done.Set();
}
main();
");
engine.Script.done.Wait(); Please send any additional questions or comments our way. Thanks! |
No description provided.
The text was updated successfully, but these errors were encountered: