Skip to content

Commit

Permalink
fix: configure v8 flags via env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
laktek committed Jul 3, 2023
1 parent f1e4fd2 commit 3b8e191
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions crates/base/src/deno_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ fn get_error_class_name(e: &AnyError) -> &'static str {
errors_rt::get_error_class_name(e).unwrap_or("Error")
}

fn set_v8_flags() {
let v8_flags = std::env::var("V8_FLAGS").unwrap_or("".to_string());
let mut vec = vec!["IGNORED"];
if v8_flags.is_empty() {
return;
}

vec.append(&mut v8_flags.split(' ').collect());
debug!(
"v8 flags unrecognized {:?}",
deno_core::v8_set_flags(vec.iter().map(|v| v.to_string()).collect())
);
}

pub struct DenoRuntime {
pub js_runtime: JsRuntime,
pub env_vars: HashMap<String, String>, // TODO: does this need to be pub?
Expand Down Expand Up @@ -121,6 +135,8 @@ impl DenoRuntime {
}
}

set_v8_flags();

let user_agent = "supabase-edge-runtime".to_string();
let base_url =
Url::from_directory_path(std::env::current_dir().map(|p| p.join(&service_path))?)
Expand Down Expand Up @@ -167,9 +183,6 @@ impl DenoRuntime {
let import_map = load_import_map(import_map_path)?;
let module_loader = DefaultModuleLoader::new(import_map, no_module_cache)?;

let ret = deno_core::v8_set_flags(vec!["IGNORED".to_string()]);
debug!("v8 flags unrecognized {:?}", ret);

let mut js_runtime = JsRuntime::new(RuntimeOptions {
extensions,
module_loader: Some(Rc::new(module_loader)),
Expand Down

0 comments on commit 3b8e191

Please sign in to comment.