Skip to content

Commit 5b76fc4

Browse files
committed
Catch panic
1 parent 0003ca4 commit 5b76fc4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/vm/src/modules/file_system_cache.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fs;
22
use std::hash::Hash;
33
use std::io;
4+
use std::panic::catch_unwind;
45
use std::path::{Path, PathBuf};
56
use thiserror::Error;
67

@@ -166,9 +167,12 @@ impl FileSystemCache {
166167
.map_err(|_e| VmError::cache_err("Error creating modules directory"))?;
167168

168169
let path = self.module_file(checksum);
169-
module
170-
.serialize_to_file(&path)
171-
.map_err(|e| VmError::cache_err(format!("Error writing module to disk: {e}")))?;
170+
catch_unwind(|| {
171+
module
172+
.serialize_to_file(&path)
173+
.map_err(|e| VmError::cache_err(format!("Error writing module to disk: {e}")))
174+
})
175+
.map_err(|_| VmError::cache_err("Could not write module to disk"))??;
172176
let module_size = module_size(&path)?;
173177
Ok(module_size)
174178
}

0 commit comments

Comments
 (0)