ReviewOS

also looking at this

craft-native/craft

fix(ios): give getPendingNotifications a deadline, on the shared block table

#247
Merged glennmichael123 wants to merge fix/ios-notification-deadlines into main
2 files +164 -60
packages/zig/test/ios_conformance_test.zigmodified+28-0
Changes to packages/zig/test/ios_conformance_test.zig
@@ -2013,6 +2013,34 @@ test "no case the page waits on casts its argument without answering the other w
20132013 }
20142014}
20152015
2016test "a module that parks a call on a completion block also gives it a deadline" {
2017 // #223: a call parked on `ios_pending` is one whose only answer comes from
2018 // a framework completion. The table makes a late completion harmless; it
2019 // does not make one that never arrives answer at all. Both halves or
2020 // neither — parking without a deadline is a promise that can wait for
2021 // ever, which is what #211 found on CI twice.
2022 var parked: usize = 0;
2023 for (zig_sources) |source| {
2024 if (std.mem.indexOf(u8, source, "ios_pending.Table(") == null) continue;
2025 parked += 1;
2026 if (std.mem.indexOf(u8, source, "scheduleDeadline(") != null) continue;
2027
2028 // Named by the first action it declares, which is how these files are
2029 // recognisable without embedding their paths.
2030 const at = std.mem.indexOf(u8, source, "pub const") orelse 0;
2031 const line_end = std.mem.indexOfScalarPos(u8, source, at, '\n') orelse at;
2032 std.debug.print(
2033 "a module parks calls on ios_pending.Table and never calls scheduleDeadline.\n" ++
2034 " Near: {s}\n" ++
2035 " A parked call whose completion never comes settles nothing at all.\n",
2036 .{source[at..line_end]},
2037 );
2038 return error.ParkedCallHasNoDeadline;
2039 }
2040 // Non-vacuity: the scan has to be finding the modules that do park.
2041 try testing.expect(parked >= 2);
2042}
2043
20162044test "every call the page waits on has a case that can resolve it" {
20172045 const region = dispatcherRegion();
20182046 var awaited = try collectAwaitedActions(testing.allocator);