1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00

feat(runtime): support creating workers using custom v8 params (#19339)

In order to limit the memory usage of isolates via heap_limits.
This commit is contained in:
Mathias Lafeldt 2023-06-05 11:22:32 +02:00 committed by Bartek Iwańczuk
parent ca625dcd1d
commit cd041fd128
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
2 changed files with 7 additions and 0 deletions

View file

@ -449,6 +449,7 @@ impl CliMainWorkerFactory {
},
extensions,
startup_snapshot: Some(crate::js::deno_isolate_init()),
create_params: None,
unsafely_ignore_certificate_errors: shared
.options
.unsafely_ignore_certificate_errors

View file

@ -95,6 +95,10 @@ pub struct WorkerOptions {
/// V8 snapshot that should be loaded on startup.
pub startup_snapshot: Option<Snapshot>,
/// Optional isolate creation parameters, such as heap limits.
pub create_params: Option<v8::CreateParams>,
pub unsafely_ignore_certificate_errors: Option<Vec<String>>,
pub root_cert_store_provider: Option<Arc<dyn RootCertStoreProvider>>,
pub seed: Option<u64>,
@ -181,6 +185,7 @@ impl Default for WorkerOptions {
blob_store: Default::default(),
extensions: Default::default(),
startup_snapshot: Default::default(),
create_params: Default::default(),
bootstrap: Default::default(),
stdio: Default::default(),
}
@ -321,6 +326,7 @@ impl MainWorker {
let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(options.module_loader.clone()),
startup_snapshot: Some(startup_snapshot),
create_params: options.create_params,
source_map_getter: options.source_map_getter,
get_error_class_fn: options.get_error_class_fn,
shared_array_buffer_store: options.shared_array_buffer_store.clone(),