Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions crates/base/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::server::{Server, ServerCodes, WorkerEntrypoints};
use anyhow::Error;
use deno_core::JsRuntime;
use log::error;
use tokio::sync::mpsc::Sender;

#[allow(clippy::too_many_arguments)]
Expand All @@ -14,6 +15,8 @@ pub async fn start_server(
callback_tx: Option<Sender<ServerCodes>>,
entrypoints: WorkerEntrypoints,
) -> Result<(), Error> {
set_v8_flags();

// NOTE(denoland/deno/20495): Due to the new PKU (Memory Protection Keys)
// feature introduced in V8 11.6, We need to initialize the V8 platform on
// the main thread that spawns V8 isolates.
Expand All @@ -32,3 +35,20 @@ pub async fn start_server(
.await?;
server.listen().await
}

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

if v8_flags.is_empty() {
return;
}

vec.append(&mut v8_flags.split(' ').collect());

let ignored = deno_core::v8_set_flags(vec.iter().map(|v| v.to_string()).collect());

if *ignored.as_slice() != [""] {
error!("v8 flags unrecognized {:?}", ignored);
}
}
16 changes: 0 additions & 16 deletions crates/base/src/deno_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,6 @@ fn get_error_class_name(e: &AnyError) -> &'static str {
sb_core::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());
error!(
"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 All @@ -95,8 +81,6 @@ impl DenoRuntime {
maybe_module_code,
} = opts;

set_v8_flags();

let user_agent = "supabase-edge-runtime".to_string();
let base_dir_path = std::env::current_dir().map(|p| p.join(&service_path))?;
let base_url = Url::from_directory_path(&base_dir_path).unwrap();
Expand Down