Skip to content

Commit a005bdb

Browse files
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a69ab64 commit a005bdb

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/js-host-api/src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,9 @@ impl JSSandboxWrapper {
812812
/// Calling `dispose()` on an already-consumed sandbox is a no-op.
813813
#[napi]
814814
pub fn dispose(&self) -> napi::Result<()> {
815-
let _ = self.inner.lock().map_err(|_| lock_error())?.take();
815+
if let Ok(mut guard) = self.inner.lock() {
816+
let _ = guard.take();
817+
}
816818
Ok(())
817819
}
818820
}
@@ -1174,9 +1176,14 @@ impl LoadedJSSandboxWrapper {
11741176
///
11751177
/// Calling `dispose()` on an already-consumed sandbox is a no-op.
11761178
#[napi]
1177-
pub fn dispose(&self) -> napi::Result<()> {
1178-
let _ = self.inner.lock().map_err(|_| lock_error())?.take();
1179-
Ok(())
1179+
pub async fn dispose(&self) -> napi::Result<()> {
1180+
let inner = self.inner.clone();
1181+
tokio::task::spawn_blocking(move || {
1182+
let _ = inner.lock().map_err(|_| lock_error())?.take();
1183+
Ok(())
1184+
})
1185+
.await
1186+
.map_err(join_error)?
11801187
}
11811188
}
11821189

0 commit comments

Comments
 (0)