Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): back off before re-signing a manifest URL that timed out

Richie McIlroy1387ea9d2a56
diff --git a/apps/desktop-gpui/src/upload.rs b/apps/desktop-gpui/src/upload.rs
index fa872165a..a50019544 100644
--- a/apps/desktop-gpui/src/upload.rs
+++ b/apps/desktop-gpui/src/upload.rs
@@ -1222,9 +1222,16 @@ async fn upload_segment_manifest(
transport.keep_manifest_target(Some(reusable));
return Ok(());
}
- Err(error) => {
+ Err(error @ AuthApiError::Status(..)) => {
check_segment_cancelled(cancel)?;
- tracing::debug!("Reused instant manifest URL failed; signing a new one: {error}");
+ tracing::debug!(
+ "Reused instant manifest URL was rejected; signing a new one: {error}"
+ );
+ }
+ Err(error) => {
+ return Err(format!(
+ "Failed to upload instant recording manifest: {error}"
+ ));
}
}
}
diff --git a/apps/desktop-gpui/src/upload/verify_tests.rs b/apps/desktop-gpui/src/upload/verify_tests.rs
index 751cce8f4..5e0d18491 100644
--- a/apps/desktop-gpui/src/upload/verify_tests.rs
+++ b/apps/desktop-gpui/src/upload/verify_tests.rs
@@ -1660,6 +1660,39 @@ fn instant_live_manifest_signs_a_new_url_when_the_reused_one_fails() {
);
}
+/// A reused URL that times out is not retried at once with a fresh one: the
+/// attempt fails and the manifest retry loop backs off first, so a hung
+/// network costs one request timeout per attempt, as before.
+#[test]
+fn instant_live_manifest_timeout_on_the_reused_url_backs_off_before_resigning() {
+ instant_case(
+ "instant_live_manifest_reuse_timeout",
+ vec![rule(Route::Object("segments/manifest.json"), Fault::Hang)],
+ budget::INSTANT_LIVE_MANIFEST_403,
+ |mock, run| {
+ assert_instant_complete(mock, &run);
+ let hung = mock
+ .responses("PUT", "segments/manifest.json")
+ .into_iter()
+ .find(|(status, _)| *status == 0)
+ .map(|(_, at)| at)
+ .expect("no hung manifest PUT");
+ let resigned = mock
+ .responses("POST", "/api/upload/signed")
+ .into_iter()
+ .filter(|(_, at)| *at > hung)
+ .map(|(_, at)| at)
+ .min()
+ .unwrap_or_else(|| panic!("manifest was never re-signed:\n{}", mock.timeline()));
+ assert!(
+ resigned >= hung + Duration::from_secs(5 * 60) + Duration::from_millis(200),
+ "re-signed without backing off:\n{}",
+ mock.timeline()
+ );
+ },
+ );
+}
+
#[test]
fn instant_live_manifest_url_is_resigned_before_it_can_expire() {
let scratch = Scratch::new("instant_live_manifest_url_expiry");