summaryrefslogtreecommitdiffstats
path: root/zellij-server
diff options
context:
space:
mode:
authorhar7an <99636919+har7an@users.noreply.github.com>2022-11-12 10:18:15 +0000
committerGitHub <noreply@github.com>2022-11-12 10:18:15 +0000
commit342d1629d08f429a8cb56150401f169c7f1e6b97 (patch)
tree654b3b4fa37d6c4d92475ba5c7b951fa96f35438 /zellij-server
parentb52ca5d13f64a507f6f8b05b3cdd06c94560556a (diff)
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
Diffstat (limited to 'zellij-server')
-rw-r--r--zellij-server/src/terminal_bytes.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/zellij-server/src/terminal_bytes.rs b/zellij-server/src/terminal_bytes.rs
index d313ec5d1..6b81a01bf 100644
--- a/zellij-server/src/terminal_bytes.rs
+++ b/zellij-server/src/terminal_bytes.rs
@@ -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(