File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
## [ Unreleased]
11
11
12
+ - Fix ` panic ` when dropping a ` SyncWrapper ` while it is still executing the ` interact ` method.
13
+
12
14
## [ 0.1.3] - 2024-05-24
13
15
14
16
- Add ` LICENSE-APACHE ` and ` LICENSE-MIT ` files to published crates
Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ pub enum InteractError {
37
37
/// Provided callback has panicked.
38
38
Panic ( Box < dyn Any + Send + ' static > ) ,
39
39
40
- /// Callback was aborted.
40
+ /// Callback was aborted. This variant needs to exist for technical
41
+ /// reasons but you should never actually be able to get this as a
42
+ /// return value when calling `SyncWrapper::interact`.
41
43
Aborted ,
42
44
}
43
45
@@ -119,13 +121,13 @@ where
119
121
self . runtime
120
122
. spawn_blocking ( move || {
121
123
let mut guard = arc. lock ( ) . unwrap ( ) ;
122
- let conn = guard. as_mut ( ) . unwrap ( ) ;
124
+ let conn: & mut T = guard. as_mut ( ) . ok_or ( InteractError :: Aborted ) ? ;
123
125
#[ cfg( feature = "tracing" ) ]
124
126
let _span = span. enter ( ) ;
125
- f ( conn)
127
+ Ok ( f ( conn) )
126
128
} )
127
129
. await
128
- . map_err ( |SpawnBlockingError :: Panic ( p) | InteractError :: Panic ( p) )
130
+ . map_err ( |SpawnBlockingError :: Panic ( p) | InteractError :: Panic ( p) ) ?
129
131
}
130
132
131
133
/// Indicates whether the underlying [`Mutex`] has been poisoned.
You can’t perform that action at this time.
0 commit comments