Skip to content

Commit 5772b5b

Browse files
nholland94georgeee
authored andcommitted
Revert "Merge pull request #14397 from MinaProtocol/fix/itn-mangled-errors"
This reverts commit 4c629a1, reversing changes made to 55b7818.
1 parent c22e2f1 commit 5772b5b

File tree

2 files changed

+9
-42
lines changed

2 files changed

+9
-42
lines changed

src/lib/gossip_net/libp2p.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ module Make (Rpc_intf : Network_peer.Rpc_intf.Rpc_interface_intf) :
217217
| Mina_net2.Libp2p_helper_died_unexpectedly ->
218218
on_unexpected_termination ()
219219
| _ ->
220-
Exn.reraise exn "Mina_net2 raised an exception"
220+
raise exn
221221
in
222222
let%bind seeds_from_url =
223223
match config.seed_peer_list_url with

src/lib/o1trace/o1trace.ml

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ let thread name f =
8686
let ctx = with_o1trace ~name ctx in
8787
match Scheduler.within_context ctx f with
8888
| Error () ->
89-
(* Scheduler.within_context will send the actual error to the parent monitor asynchronously.
90-
* At this point, the thread has crashed, so we just return a Deferred that will never resolve *)
91-
Deferred.create (Fn.const ())
89+
failwithf
90+
"timing task `%s` failed, exception reported to parent monitor" name
91+
()
9292
| Ok x ->
9393
x )
9494

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

127126
let%test_module "thread tests" =
128127
( module struct
129-
exception Test_exn
130-
131-
let is_test_exn exn =
132-
(* 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 *)
133-
String.is_substring (Exn.to_string exn) ~substring:"(Test_exn)"
134-
135128
let child_of n =
136129
match
137130
let prev_sync_fiber = !current_sync_fiber in
@@ -221,31 +214,5 @@ let%test_module "thread tests" =
221214
Deferred.unit ) ) ) ;
222215
Deferred.unit ) ) )
223216

224-
let%test_unit "exceptions are handled properly when raised in first cycle \
225-
of a thread" =
226-
test (fun stop ->
227-
match%map
228-
Monitor.try_with (fun () ->
229-
thread "test" (fun () -> raise Test_exn) )
230-
with
231-
| Ok _ ->
232-
failwith "expected a failure"
233-
| Error exn ->
234-
assert (is_test_exn exn) ;
235-
stop () )
236-
237-
let%test_unit "exceptions are handled properly when raised in first cycle \
238-
of a sync_thread" =
239-
test (fun stop ->
240-
match%map
241-
Monitor.try_with (fun () ->
242-
sync_thread "test" (fun () -> raise Test_exn) )
243-
with
244-
| Ok _ ->
245-
failwith "expected a failure"
246-
| Error exn ->
247-
assert (is_test_exn exn) ;
248-
stop () )
249-
250217
(* TODO: recursion tests *)
251218
end )

0 commit comments

Comments
 (0)