Skip to content

Commit

Permalink
Revert "Merge pull request #14397 from MinaProtocol/fix/itn-mangled-e…
Browse files Browse the repository at this point in the history
…rrors"

This reverts commit 4c629a1, reversing
changes made to 55b7818.
  • Loading branch information
nholland94 authored and georgeee committed Nov 23, 2023
1 parent f0c03b8 commit ce34ca5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/lib/gossip_net/libp2p.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ module Make (Rpc_intf : Network_peer.Rpc_intf.Rpc_interface_intf) :
| Mina_net2.Libp2p_helper_died_unexpectedly ->
on_unexpected_termination ()
| _ ->
Exn.reraise exn "Mina_net2 raised an exception"
raise exn
in
let%bind seeds_from_url =
match config.seed_peer_list_url with
Expand Down
49 changes: 8 additions & 41 deletions src/lib/o1trace/o1trace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ let thread name f =
let ctx = with_o1trace ~name ctx in
match Scheduler.within_context ctx f with
| Error () ->
(* Scheduler.within_context will send the actual error to the parent monitor asynchronously.
* At this point, the thread has crashed, so we just return a Deferred that will never resolve *)
Deferred.create (Fn.const ())
failwithf
"timing task `%s` failed, exception reported to parent monitor" name
()
| Ok x ->
x )

Expand All @@ -102,12 +102,11 @@ let sync_thread name f =
let start_time = Time_ns.now () in
let ctx = Scheduler.current_execution_context () in
let ctx = with_o1trace ~name ctx in
match
Scheduler.Private.with_execution_context (Scheduler.Private.t ()) ctx
~f:(fun () -> Result.try_with f)
with
| Error exn ->
Exn.reraise exn "exception caught by O1trace.sync_thread"
match Scheduler.within_context ctx f with
| Error () ->
failwithf
"sync timing task `%s` failed, exception reported to parent monitor"
name ()
| Ok result ->
let elapsed_time = Time_ns.abs_diff (Time_ns.now ()) start_time in
on_job_exit' fiber elapsed_time ;
Expand All @@ -126,12 +125,6 @@ let () =

let%test_module "thread tests" =
( module struct
exception Test_exn

let is_test_exn exn =
(* there isn't a great way to compare the exn to the one that was thrown due to how async mangles the exn, so we do this instead *)
String.is_substring (Exn.to_string exn) ~substring:"(Test_exn)"

let child_of n =
match
let prev_sync_fiber = !current_sync_fiber in
Expand Down Expand Up @@ -221,31 +214,5 @@ let%test_module "thread tests" =
Deferred.unit ) ) ) ;
Deferred.unit ) ) )

let%test_unit "exceptions are handled properly when raised in first cycle \
of a thread" =
test (fun stop ->
match%map
Monitor.try_with (fun () ->
thread "test" (fun () -> raise Test_exn) )
with
| Ok _ ->
failwith "expected a failure"
| Error exn ->
assert (is_test_exn exn) ;
stop () )

let%test_unit "exceptions are handled properly when raised in first cycle \
of a sync_thread" =
test (fun stop ->
match%map
Monitor.try_with (fun () ->
sync_thread "test" (fun () -> raise Test_exn) )
with
| Ok _ ->
failwith "expected a failure"
| Error exn ->
assert (is_test_exn exn) ;
stop () )

(* TODO: recursion tests *)
end )

0 comments on commit ce34ca5

Please sign in to comment.