Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors: Ignore errors from async when quitting #1918

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]

* feat: support text input from clipboard (https://github.com/zellij-org/zellij/pull/1926)
* errors: Don't log errors from panes when quitting zellij (https://github.com/zellij-org/zellij/pull/1918)

## [0.33.0] - 2022-11-10

Expand Down
20 changes: 17 additions & 3 deletions zellij-server/src/terminal_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,23 @@ impl TerminalBytes {
},
}
}
self.async_send_to_screen(ScreenInstruction::Render)
.await
.with_context(err_context)?;

// Ignore any errors that happen here.
// We only leave the loop above when the pane exits. This can happen in a lot of ways, but
// the most problematic is when quitting zellij with `Ctrl+q`. That is because the channel
// for `Screen` will have exited already, so this send *will* fail. This isn't a problem
// per-se because the application terminates anyway, but it will print a lengthy error
// message into the log for every pane that was still active when we quit the application.
// This:
//
// 1. Makes the log rather pointless, because even when the application exits "normally",
// there will be errors inside and
// 2. Leaves the impression we have a bug in the code and can't terminate properly
//
// FIXME: Ideally we detect whether the application is being quit and only ignore the error
// in that particular case?
let _ = self.async_send_to_screen(ScreenInstruction::Render).await;

Ok(())
}
async fn async_send_to_screen(
Expand Down
13 changes: 7 additions & 6 deletions zellij-utils/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,14 @@ mod not_wasm {
Err(e) => {
let (msg, context) = e.into_inner();
if *crate::consts::DEBUG_MODE.get().unwrap_or(&true) {
Err(
crate::anyhow::anyhow!("failed to send message to channel: {:#?}", msg)
.context(context.to_string()),
)
Err(crate::anyhow::anyhow!(
"failed to send message to channel: {:#?}",
msg
))
.with_context(|| context.to_string())
} else {
Err(crate::anyhow::anyhow!("failed to send message to channel")
.context(context.to_string()))
Err(crate::anyhow::anyhow!("failed to send message to channel"))
.with_context(|| context.to_string())
}
},
}
Expand Down