mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Enhance VFS initialization and error handling
- Introduced a new method `new_default_with_errors` in the VFS implementation to create a VFS instance with a critical error receiver for monitoring watcher health. - Updated the `ServeSession` constructor to accept an optional critical error receiver, allowing for better error management during session initialization. - Adjusted various calls to `ServeSession::new` across the codebase to accommodate the new parameter, ensuring consistent error handling. - Improved logging in the API context and serve session files for better clarity during server operations. These changes enhance the robustness of the VFS and session management, providing better tools for error detection and handling.
This commit is contained in:
parent
ec7f91017b
commit
8462c06b82
14 changed files with 1784 additions and 1600 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -81,7 +81,7 @@ impl BuildCommand {
|
|||
let vfs = Vfs::new_default();
|
||||
vfs.set_watch_enabled(self.watch);
|
||||
|
||||
let session = ServeSession::new(vfs, project_path)?;
|
||||
let session = ServeSession::new(vfs, project_path, None)?;
|
||||
let mut cursor = session.message_queue().cursor();
|
||||
|
||||
write_model(&session, &output_path, output_kind)?;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ fn initialize_plugin() -> anyhow::Result<ServeSession> {
|
|||
in_memory_fs.load_snapshot("/plugin", plugin_snapshot)?;
|
||||
|
||||
let vfs = Vfs::new(in_memory_fs);
|
||||
Ok(ServeSession::new(vfs, "/plugin")?)
|
||||
Ok(ServeSession::new(vfs, "/plugin", None)?)
|
||||
}
|
||||
|
||||
fn install_plugin() -> anyhow::Result<()> {
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ impl ServeCommand {
|
|||
pub fn run(self) -> anyhow::Result<()> {
|
||||
let project_path = resolve_path(&self.project);
|
||||
|
||||
let vfs = Vfs::new_default();
|
||||
let (vfs, critical_errors) = Vfs::new_default_with_errors();
|
||||
|
||||
let session = Arc::new(ServeSession::new(vfs, project_path)?);
|
||||
let session = Arc::new(ServeSession::new(vfs, project_path, Some(critical_errors))?);
|
||||
|
||||
let ip = self
|
||||
.address
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ impl SourcemapCommand {
|
|||
let vfs = Vfs::new_default();
|
||||
vfs.set_watch_enabled(self.watch);
|
||||
|
||||
let session = ServeSession::new(vfs, project_path)?;
|
||||
let session = ServeSession::new(vfs, project_path, None)?;
|
||||
let mut cursor = session.message_queue().cursor();
|
||||
|
||||
let filter = if self.include_non_scripts {
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ impl SyncbackCommand {
|
|||
let vfs = Vfs::new_oneshot();
|
||||
|
||||
let project_start_timer = Instant::now();
|
||||
let session_old = ServeSession::new(vfs, path_old.clone())?;
|
||||
let session_old = ServeSession::new(vfs, path_old.clone(), None)?;
|
||||
log::debug!(
|
||||
"Finished opening project in {:0.02}s",
|
||||
project_start_timer.elapsed().as_secs_f32()
|
||||
|
|
@ -251,7 +251,7 @@ impl SyncbackCommand {
|
|||
// cases, we log a warning but don't fail the syncback.
|
||||
let sourcemap_path = base_path.join("sourcemap.json");
|
||||
let sourcemap_vfs = Vfs::new_oneshot();
|
||||
match ServeSession::new(sourcemap_vfs, path_old.clone()) {
|
||||
match ServeSession::new(sourcemap_vfs, path_old.clone(), None) {
|
||||
Ok(sourcemap_session) => {
|
||||
write_sourcemap(
|
||||
&sourcemap_session,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl UploadCommand {
|
|||
|
||||
let vfs = Vfs::new_default();
|
||||
|
||||
let session = ServeSession::new(vfs, project_path)?;
|
||||
let session = ServeSession::new(vfs, project_path, None)?;
|
||||
|
||||
let tree = session.tree();
|
||||
let inner_tree = tree.inner();
|
||||
|
|
|
|||
|
|
@ -117,7 +117,11 @@ impl ServeSession {
|
|||
/// The project file is expected to be loaded out-of-band since it's
|
||||
/// currently loaded from the filesystem directly instead of through the
|
||||
/// in-memory filesystem layer.
|
||||
pub fn new<P: AsRef<Path>>(vfs: Vfs, start_path: P) -> Result<Self, ServeSessionError> {
|
||||
pub fn new<P: AsRef<Path>>(
|
||||
vfs: Vfs,
|
||||
start_path: P,
|
||||
critical_error_receiver: Option<crossbeam_channel::Receiver<memofs::WatcherCriticalError>>,
|
||||
) -> Result<Self, ServeSessionError> {
|
||||
let start_path = start_path.as_ref();
|
||||
let start_time = Instant::now();
|
||||
|
||||
|
|
@ -158,6 +162,7 @@ impl ServeSession {
|
|||
tree_mutation_receiver,
|
||||
Arc::clone(&suppressed_paths),
|
||||
root_project.folder_location().to_path_buf(),
|
||||
critical_error_receiver,
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue