summaryrefslogtreecommitdiff
path: root/runtime/worker.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2022-04-15 15:08:09 +0100
committerGitHub <noreply@github.com>2022-04-15 16:08:09 +0200
commit8b31fc23cd80de9baa62535e95367da7a21c9cfd (patch)
tree994748bd06ed5b4953929392107b6beaa1c1c337 /runtime/worker.rs
parentb4af648c1515a8e79d7a5d1b14d8a4ba9d966a72 (diff)
refactor: Move source map lookups to core (#14274)
The following transformations gradually faced by "JsError" have all been moved up front to "JsError::from_v8_exception()": - finding the first non-"deno:" source line; - moving "JsError::script_resource_name" etc. into the first error stack in case of syntax errors; - source mapping "JsError::script_resource_name" etc. when wrapping the error even though the frame locations are source mapped earlier; - removing "JsError::{script_resource_name,line_number,start_column,end_column}" entirely in favour of "js_error.frames.get(0)". We also no longer pass a js-side callback to "core/02_error.js" from cli. I avoided doing this on previous occasions because the source map lookups were in an awkward place.
Diffstat (limited to 'runtime/worker.rs')
-rw-r--r--runtime/worker.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 983f174aa..fa147a7e6 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -20,6 +20,7 @@ use deno_core::ModuleLoader;
use deno_core::ModuleSpecifier;
use deno_core::RuntimeOptions;
use deno_core::SharedArrayBufferStore;
+use deno_core::SourceMapGetter;
use deno_tls::rustls::RootCertStore;
use deno_web::BlobStore;
use log::debug;
@@ -54,6 +55,7 @@ pub struct WorkerOptions {
// Callbacks invoked when creating new instance of WebWorker
pub create_web_worker_cb: Arc<ops::worker_host::CreateWebWorkerCb>,
pub web_worker_preload_module_cb: Arc<ops::worker_host::PreloadModuleCb>,
+ pub source_map_getter: Option<Box<dyn SourceMapGetter>>,
pub js_error_create_fn: Option<Rc<JsErrorCreateFn>>,
pub maybe_inspector_server: Option<Arc<InspectorServer>>,
pub should_break_on_first_statement: bool,
@@ -155,6 +157,7 @@ impl MainWorker {
let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(options.module_loader.clone()),
startup_snapshot: Some(js::deno_isolate_init()),
+ source_map_getter: options.source_map_getter,
js_error_create_fn: options.js_error_create_fn.clone(),
get_error_class_fn: options.get_error_class_fn,
shared_array_buffer_store: options.shared_array_buffer_store.clone(),
@@ -357,7 +360,6 @@ mod tests {
let options = WorkerOptions {
bootstrap: BootstrapOptions {
- apply_source_maps: false,
args: vec![],
cpu_count: 1,
debug_flag: false,
@@ -374,6 +376,7 @@ mod tests {
unsafely_ignore_certificate_errors: None,
root_cert_store: None,
seed: None,
+ source_map_getter: None,
js_error_create_fn: None,
web_worker_preload_module_cb: Arc::new(|_| unreachable!()),
create_web_worker_cb: Arc::new(|_| unreachable!()),