summaryrefslogtreecommitdiff
path: root/cli/tools/repl/session.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/repl/session.rs')
-rw-r--r--cli/tools/repl/session.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs
index b636a4949..f67396d42 100644
--- a/cli/tools/repl/session.rs
+++ b/cli/tools/repl/session.rs
@@ -12,7 +12,9 @@ use deno_ast::DiagnosticsError;
use deno_ast::ImportsNotUsedAsValues;
use deno_ast::ModuleSpecifier;
use deno_core::error::AnyError;
+use deno_core::futures::channel::mpsc::UnboundedReceiver;
use deno_core::futures::FutureExt;
+use deno_core::futures::StreamExt;
use deno_core::serde_json;
use deno_core::serde_json::Value;
use deno_core::LocalInspectorSession;
@@ -92,6 +94,10 @@ pub struct ReplSession {
pub language_server: ReplLanguageServer,
has_initialized_node_runtime: bool,
referrer: ModuleSpecifier,
+ // FIXME(bartlomieju): this field should be used to listen
+ // for "exceptionThrown" notifications
+ #[allow(dead_code)]
+ notification_rx: UnboundedReceiver<Value>,
}
impl ReplSession {
@@ -113,8 +119,11 @@ impl ReplSession {
// Enabling the runtime domain will always send trigger one executionContextCreated for each
// context the inspector knows about so we grab the execution context from that since
// our inspector does not support a default context (0 is an invalid context id).
- let mut context_id: u64 = 0;
- for notification in session.notifications() {
+ let context_id: u64;
+ let mut notification_rx = session.take_notification_rx();
+
+ loop {
+ let notification = notification_rx.next().await.unwrap();
let method = notification.get("method").unwrap().as_str().unwrap();
let params = notification.get("params").unwrap();
if method == "Runtime.executionContextCreated" {
@@ -127,6 +136,7 @@ impl ReplSession {
.as_bool()
.unwrap());
context_id = context.get("id").unwrap().as_u64().unwrap();
+ break;
}
}
assert_ne!(context_id, 0);
@@ -141,6 +151,7 @@ impl ReplSession {
language_server,
has_initialized_node_runtime: false,
referrer,
+ notification_rx,
};
// inject prelude