mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-24 17:53:36 +03:00
Errors: Ignore errors from async when quitting (#1918)
* utils/errors: Fix function order in `to_anyhow` impl for `SendError`. Previously we attached the context to `anyhow!`, which is wrong (because it doesn't create an `Err` type itself) and leads to strange behavior where the error seemingly is immediately panicked upon. Instead, Wrap `anyhow!` into an `Err()` and then attach the context to that. This achieves the intended goal and doesn't lead to premature termination. * server/terminal_bytes: Ignore error in `listen` which occurs when quitting zellij with the `Ctrl+q` keybinding. At the end of the `listen` function we break out of a loop and send a final `Render` instruction to the Screen. However, when quitting zellij as mentioned above, the Screen thread is likely dead already and hence we cannot send it any Instructions. This causes an error in the async tasks of the panes that handle reading the PTY input. If we leave the error unhandled, we will have error messages in the log whenever we quit zellij, even though the application exited normally. Hence, we now send the final `Render` instruction but do not care whether it is sent successfully or not. This is a "workaround" for the fact that we cannot tell whether the application is quitting or not. * server/terminal_bytes: Add FIXME note * changelog: Add PR #1918 don't log errors from async pane threads when quitting zellij
This commit is contained in:
parent
b52ca5d13f
commit
342d1629d0
@ -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
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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())
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user