Skip to main content

max / quasi-type

Ask a mirror once, quietly The mirror attempt was reusing the upstream fetch's flags and both were wrong for it. --retry-all-errors retries a 404, so a mirror that does not have the file cost five retries and four delays per file before the build reached the url that was always going to answer; --show-error printed curl: (22) 404 for each, which reads as a build failing rather than as a fallback working. Measured on an Alloy rust-stage build against a mirror that is committed but not yet deployed. Ask once, say nothing, and give up quickly. Upstream keeps the hard retry it exists for.
Co-Authored-By
Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session
https://claude.ai/code/session_0153yKAYUmoC9bZz2eV6cA88
Author: Max Johnson <me@maxj.phd> · 2026-08-29 17:34 UTC
Signed with PGP, not checked
Commit: 52c5bc069fa0b0f3f74bad6957e2d5ca12c0b57d
Parent: 43845e3
3 files changed, +62 insertions, -28 deletions
M Cargo.lock +13 -13
@@ -290,7 +290,7 @@
290 290
291 291 [[package]]
292 292 name = "quasi-type"
293 - version = "0.1.2"
293 + version = "0.1.3"
294 294 dependencies = [
295 295 "brotli",
296 296 "font-types",
@@ -526,10 +526,6 @@
526 526 "simd-adler32",
527 527 ]
528 528
529 - [[patch.unused]]
530 - name = "docengine"
531 - version = "0.7.0"
532 -
533 529 [[patch.unused]]
534 530 name = "kberg"
535 531 version = "0.1.0"
@@ -546,6 +542,10 @@
546 542 name = "tagtree"
547 543 version = "0.4.1"
548 544
545 + [[patch.unused]]
546 + name = "docengine"
547 + version = "0.7.0"
548 +
549 549 [[patch.unused]]
550 550 name = "synckit-client"
551 551 version = "0.10.0"
@@ -556,27 +556,27 @@
556 556
557 557 [[patch.unused]]
558 558 name = "quasi-axum"
559 - version = "0.74.0"
559 + version = "0.79.0"
560 560
561 561 [[patch.unused]]
562 562 name = "quasi-basics"
563 - version = "0.74.0"
563 + version = "0.79.0"
564 564
565 565 [[patch.unused]]
566 566 name = "quasi-http"
567 - version = "0.74.0"
567 + version = "0.79.0"
568 568
569 569 [[patch.unused]]
570 570 name = "quasi-immediate"
571 - version = "0.74.0"
571 + version = "0.79.0"
572 572
573 573 [[patch.unused]]
574 574 name = "quasi-notifs"
575 - version = "0.74.0"
575 + version = "0.79.0"
576 576
577 577 [[patch.unused]]
578 578 name = "quasi-router"
579 - version = "0.74.0"
579 + version = "0.79.0"
580 580
581 581 [[patch.unused]]
582 582 name = "quasi-store"
@@ -584,8 +584,8 @@
584 584
585 585 [[patch.unused]]
586 586 name = "quasi-tauri"
587 - version = "0.74.0"
587 + version = "0.79.0"
588 588
589 589 [[patch.unused]]
590 590 name = "quasi-webview"
591 - version = "0.74.0"
591 + version = "0.79.0"
M Cargo.toml +1 -1
@@ -1,6 +1,6 @@
1 1 [package]
2 2 name = "quasi-type"
3 - version = "0.1.2"
3 + version = "0.1.3"
4 4 edition = "2024"
5 5 description = "The house font pipeline: a pinned base face plus the house glyph set in, a Quasi <Slot> face out."
6 6 license = "MIT"
M src/base.rs +48 -14
@@ -587,6 +587,11 @@
587 587 /// machine with no access to our infrastructure still builds, so the mirror
588 588 /// adds a source rather than moving the project onto one.
589 589 ///
590 + /// The mirror attempt is quiet and gives up quickly ([`Attempt::Mirror`]),
591 + /// because it is spent before a request that is going to be made anyway when it
592 + /// fails. Retrying a 404 or printing curl's error would make an absent mirror
593 + /// cost more than no mirror, which is the one thing this must not do.
594 + ///
590 595 /// `expect` is the pinned digest, and it is checked *here* for a mirrored file
591 596 /// rather than only by the caller. A mirror serving the wrong bytes has to fall
592 597 /// through to upstream, not fail the build: without that, an out-of-date mirror
@@ -602,7 +607,7 @@
602 607 });
603 608 }
604 609 let mirror = mirrored(expect).filter(|mirror| {
605 - fetch(mirror, path).is_ok()
610 + fetch_with(mirror, path, Attempt::Mirror).is_ok()
606 611 && std::fs::read(path).is_ok_and(|bytes| verify(&bytes, expect).is_ok())
607 612 });
608 613 if mirror.is_none() {
@@ -696,23 +701,52 @@
696 701 /// `3d41d15a`). [`MIRROR_ENV`] is this end of that: point it at a host we run
697 702 /// and the pinned files come from there, with upstream still the fallback.
698 703 fn fetch(url: &str, dest: &Path) -> Result<(), Error> {
704 + fetch_with(url, dest, Attempt::Upstream)
705 + }
706 +
707 + /// Which of the two fetches this is, because they want opposite curl flags.
708 + ///
709 + /// Split out after the first build against a mirror that was not there yet: the
710 + /// mirror attempt inherited [`Attempt::Upstream`]'s flags and both of them were
711 + /// wrong for it. `--retry-all-errors` retries a 404, so four files the mirror
712 + /// did not have cost five retries and four delays each before the build reached
713 + /// the url that would answer; and `--show-error` printed `curl: (22) ... 404`
714 + /// four times, which reads as a build failing rather than as a fallback working.
715 + #[derive(Clone, Copy)]
716 + enum Attempt {
717 + /// The pinned url. Retry hard: this is the one that has to work, and the
718 + /// failure it is retrying through is somebody else's rate limiter.
719 + Upstream,
720 + /// A mirror, which is allowed not to have the file. Ask once, say nothing,
721 + /// and give up quickly, because every second here is spent before the
722 + /// request that was always going to be made anyway.
723 + Mirror,
724 + }
725 +
726 + fn fetch_with(url: &str, dest: &Path, attempt: Attempt) -> Result<(), Error> {
699 727 if let Some(parent) = dest.parent() {
700 728 std::fs::create_dir_all(parent).map_err(|e| Error::Io(parent.to_path_buf(), e))?;
701 729 }
702 730 let partial = dest.with_extension("part");
703 - let status = Command::new("curl")
704 - .args([
705 - "--fail",
706 - "--location",
707 - "--silent",
708 - "--show-error",
709 - "--retry",
710 - "5",
711 - "--retry-delay",
712 - "2",
713 - "--retry-all-errors",
714 - "--output",
715 - ])
731 + let mut curl = Command::new("curl");
732 + curl.args(["--fail", "--location", "--silent"]);
733 + match attempt {
734 + Attempt::Upstream => {
735 + curl.args([
736 + "--show-error",
737 + "--retry",
738 + "5",
739 + "--retry-delay",
740 + "2",
741 + "--retry-all-errors",
742 + ]);
743 + }
744 + Attempt::Mirror => {
745 + curl.args(["--connect-timeout", "10", "--max-time", "120"]);
746 + }
747 + }
748 + let status = curl
749 + .arg("--output")
716 750 .arg(&partial)
717 751 .arg(url)
718 752 .status()