upstream: an unnamed connect errno fails over, local-resource exchanges are counted, doh faults carry the http status

This commit is contained in:
2026-10-20 10:11:34 +02:00
parent 2697adfa27
commit 8efe504c51
8 changed files with 191 additions and 15 deletions
+17 -5
View File
@@ -56,10 +56,10 @@ comptime {
pub const window_len = 32;
/// Bytes kept of a rendered `transport.Fault`, truncated to fit. Sized so the
/// widest classification and the widest concrete cause name fit whole; the
/// comptime-driven test below recomputes that worst case from the std error
/// sets, so a wider name std adds fails the test run rather than silently
/// truncating an operator's only diagnostic.
/// widest classification and the widest concrete cause name fit whole, and so
/// does the widest HTTP status with its phrase; the comptime-driven test below
/// recomputes that worst case from std, so a wider name std adds fails the test
/// run rather than silently truncating an operator's only diagnostic.
pub const error_name_capacity = 64;
/// The shift is capped so `base_backoff_ms << shift` cannot run away; by then
@@ -552,7 +552,7 @@ test "lastError truncates a cause too wide for the buffer instead of overflowing
try testing.expectEqualStrings(whole[0..error_name_capacity], state.lastError());
}
test "error_name_capacity holds the widest classification and cause whole" {
test "error_name_capacity holds the widest classification, cause and status whole" {
// The widest concrete cause an upstream unwrap can produce. The three sets
// are the ones `transport.zig`'s unwraps return a member of; a wider name
// std adds fails here rather than truncating an operator's diagnostic.
@@ -579,6 +579,18 @@ test "error_name_capacity holds the widest classification and cause whole" {
try testing.expectEqualStrings("DetectingNetworkConfigurationFailed", widest_cause);
try testing.expect(widest_kind.len + " (cause ".len + widest_cause.len + ")".len <= error_name_capacity);
const widest_phrase = comptime blk: {
var widest: []const u8 = "";
for (@typeInfo(std.http.Status).@"enum".fields) |field| {
const phrase = @as(std.http.Status, @enumFromInt(field.value)).phrase() orelse continue;
if (phrase.len > widest.len) widest = phrase;
}
break :blk widest;
};
// `std.http.Status` is a u10, so a code has at most four digits.
const widest_status = "HttpStatus (status ".len + 4 + " ".len + widest_phrase.len + ")".len;
try testing.expect(widest_status <= error_name_capacity);
}
/// The fault of a `tripped` effect, or an error when the effect says `clear`.