Skip to content

Commit 2ef8901

Browse files
committed
Added note to help people trying to debug with println from the renderer process
1 parent 3e72668 commit 2ef8901

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/messenger.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ pub fn read_forever<R: Read, T: DeserializeOwned, F: FnMut(T) -> Result<(), ()>>
2929
}
3030

3131
let result = serde_json::from_str(&buffer).map_err(|err| match err.classify() {
32+
// In addition to cases where the JSON formatting is incorrect for some reason, this
33+
// panic will occur if you use `println!` from inside the renderer process. This is
34+
// because anything sent to stdout from within the renderer process is parsed as JSON.
35+
// To avoid that and still be able to debug, switch to using the `eprintln!` macro
36+
// instead. That macro will write to stderr and you will be able to continue as normal.
3237
Category::Io | Category::Syntax | Category::Data => panic!(failed_to_read_result),
3338
Category::Eof => (),
3439
}).and_then(|result| handler(result));

0 commit comments

Comments
 (0)