Commit fa937d5 1 parent b413cd5 commit fa937d5 Copy full SHA for fa937d5
File tree 3 files changed +23
-2
lines changed
3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,13 @@ fn lazy_start(parent_state: ThreadSafeState) -> ResourceId {
111
111
112
112
let mut runtime = C_RUNTIME . lock ( ) . unwrap ( ) ;
113
113
runtime. spawn ( lazy ( move || {
114
+ // Tokio swallows panics. In order to actually crash when we panic, we
115
+ // have to set this custom hook.
116
+ std:: panic:: set_hook ( Box :: new ( |panic_info| {
117
+ eprintln ! ( "{}" , panic_info. to_string( ) ) ;
118
+ std:: process:: abort ( ) ;
119
+ } ) ) ;
120
+
114
121
worker. then ( move |result| -> Result < ( ) , ( ) > {
115
122
// Close resource so the future created by
116
123
// handle_worker_message_stream exits
Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ pub fn run<F>(future: F)
13
13
where
14
14
F : Future < Item = ( ) , Error = ( ) > + Send + ' static ,
15
15
{
16
+ // Tokio swallows panics. In order to actually crash when we panic, we
17
+ // have to set this custom hook.
18
+ std:: panic:: set_hook ( Box :: new ( |panic_info| {
19
+ eprintln ! ( "{}" , panic_info. to_string( ) ) ;
20
+ std:: process:: abort ( ) ;
21
+ } ) ) ;
16
22
// tokio::runtime::current_thread::run(future)
17
23
tokio:: run ( future)
18
24
}
40
46
let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
41
47
let mut executor = rt. executor ( ) ;
42
48
let mut enter = tokio_executor:: enter ( ) . expect ( "Multiple executors at once" ) ;
43
- tokio_executor:: with_default ( & mut executor, & mut enter, move |_enter| f ( ) ) ;
49
+ tokio_executor:: with_default ( & mut executor, & mut enter, move |_enter| {
50
+ // Tokio swallows panics. In order to actually crash when we panic, we
51
+ // have to set this custom hook.
52
+ std:: panic:: set_hook ( Box :: new ( |panic_info| {
53
+ eprintln ! ( "{}" , panic_info. to_string( ) ) ;
54
+ std:: process:: abort ( ) ;
55
+ } ) ) ;
56
+ f ( )
57
+ } ) ;
44
58
}
45
59
46
60
#[ derive( Debug ) ]
Original file line number Diff line number Diff line change @@ -324,7 +324,7 @@ mod tests {
324
324
onmessage = function(e) {
325
325
console.log("msg from main script", e.data);
326
326
if (e.data == "exit") {
327
- close() ;
327
+ delete window.onmessage ;
328
328
return;
329
329
} else {
330
330
console.assert(e.data === "hi");
You can’t perform that action at this time.
0 commit comments