Skip to content

Commit

Permalink
feat(runtime): support creating workers using custom v8 params (#19339)
Browse files Browse the repository at this point in the history
In order to limit the memory usage of isolates via heap_limits.
  • Loading branch information
mlafeldt authored Jun 5, 2023
1 parent 21c2c01 commit 77a950a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions runtime/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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(),
}
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 77a950a

Please sign in to comment.