From ce6b738ac08b66b0ee8bfa3f17f8510ab094d5d9 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Tue, 15 Dec 2020 00:37:08 +0800 Subject: fix(repl): recover from invalid input (#8759) --- runtime/inspector.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/inspector.rs b/runtime/inspector.rs index 89fd5bf57..fc0e793d9 100644 --- a/runtime/inspector.rs +++ b/runtime/inspector.rs @@ -859,7 +859,28 @@ impl v8::inspector::ChannelImpl for InspectorSession { message: v8::UniquePtr, ) { let raw_message = message.unwrap().string().to_string(); - let message = serde_json::from_str(&raw_message).unwrap(); + let message: serde_json::Value = match serde_json::from_str(&raw_message) { + Ok(v) => v, + Err(error) => match error.classify() { + serde_json::error::Category::Syntax => json!({ + "id": call_id, + "result": { + "result": { + "type": "error", + "description": "Unterminated string literal", + "value": "Unterminated string literal", + }, + "exceptionDetails": { + "exceptionId": 0, + "text": "Unterminated string literal", + "lineNumber": 0, + "columnNumber": 0 + }, + }, + }), + _ => panic!("Could not parse inspector message"), + }, + }; self .response_tx_map -- cgit v1.2.3