Fix crash in collab when sending worktree updates (#19678)
This pull request does a couple of things: - In29c2df73e1
, we introduced a safety guard that prevents this crash from happening again in the future by returning an error instead of panicking when the payload is too large. - In3e7a2e5c30
, we introduced chunking for updates coming from SSH servers (previously, we were sending the whole changeset and initial set of paths in their entirety). - In122b5b4
, we introduced a panic hook that sends panics to Axiom. For posterity, this is how we figured out what the panic was: ``` kubectl logs current-pod-name --previous --namespace=production ``` Release Notes: - N/A --------- Co-authored-by: Thorsten <thorsten@zed.dev> Co-authored-by: Bennet <bennet@zed.dev> Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
parent
b5aea548a8
commit
499e1459eb
5 changed files with 57 additions and 28 deletions
|
@ -630,10 +630,12 @@ impl From<Nonce> for u128 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn split_worktree_update(
|
||||
mut message: UpdateWorktree,
|
||||
max_chunk_size: usize,
|
||||
) -> impl Iterator<Item = UpdateWorktree> {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 2;
|
||||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
pub const MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE: usize = 256;
|
||||
|
||||
pub fn split_worktree_update(mut message: UpdateWorktree) -> impl Iterator<Item = UpdateWorktree> {
|
||||
let mut done_files = false;
|
||||
|
||||
let mut repository_map = message
|
||||
|
@ -647,13 +649,19 @@ pub fn split_worktree_update(
|
|||
return None;
|
||||
}
|
||||
|
||||
let updated_entries_chunk_size = cmp::min(message.updated_entries.len(), max_chunk_size);
|
||||
let updated_entries_chunk_size = cmp::min(
|
||||
message.updated_entries.len(),
|
||||
MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
|
||||
);
|
||||
let updated_entries: Vec<_> = message
|
||||
.updated_entries
|
||||
.drain(..updated_entries_chunk_size)
|
||||
.collect();
|
||||
|
||||
let removed_entries_chunk_size = cmp::min(message.removed_entries.len(), max_chunk_size);
|
||||
let removed_entries_chunk_size = cmp::min(
|
||||
message.removed_entries.len(),
|
||||
MAX_WORKTREE_UPDATE_MAX_CHUNK_SIZE,
|
||||
);
|
||||
let removed_entries = message
|
||||
.removed_entries
|
||||
.drain(..removed_entries_chunk_size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue