From 77a950aac417ba5e9bf1a48b0ec8934291376a8c Mon Sep 17 00:00:00 2001 From: Mathias Lafeldt Date: Mon, 5 Jun 2023 11:22:32 +0200 Subject: [PATCH] feat(runtime): support creating workers using custom v8 params (#19339) In order to limit the memory usage of isolates via heap_limits. --- cli/worker.rs | 1 + runtime/worker.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/cli/worker.rs b/cli/worker.rs index 6edf427ea572f4..b8bb6e941643e6 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -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 diff --git a/runtime/worker.rs b/runtime/worker.rs index 0e62decb46f1b9..10375818d01d2a 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -95,6 +95,10 @@ pub struct WorkerOptions { /// V8 snapshot that should be loaded on startup. pub startup_snapshot: Option, + + /// Optional isolate creation parameters, such as heap limits. + pub create_params: Option, + pub unsafely_ignore_certificate_errors: Option>, pub root_cert_store_provider: Option>, pub seed: Option, @@ -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(),