Skip to content

fix(jobs): de-flake webhook delivery on abrupt connection reset - #259

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
perf/deflake-slow-tests
Jul 3, 2026
Merged

fix(jobs): de-flake webhook delivery on abrupt connection reset#259
ScriptedAlchemy merged 1 commit into
masterfrom
perf/deflake-slow-tests

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

De-flake investigation

Mined the last ~12 failed CI runs across both workflows for recurring, test-level failures. Exactly three signatures recur — no others, and no test exceeds the 10s SLOW threshold (the suite is fast in aggregate, so there was no slow test to optimize):

Signature Count Status
os error 10053 / "failed to read webhook response" (Windows) Fixed here
LSP broker_cancels_partial_refresh… initialize timed out (macOS) Already fixed in #255
install-action: bash startup failure (Windows) Infra — see below

The fix (root cause, product + test)

The webhook client's read_status failed the whole delivery on any read error. A server that sent its complete HTTP response and then closed abruptly — e.g. a Windows peer resetting the socket (os error 10053) right after write_all — surfaced as failed to read webhook response even though the status line had already arrived. That's the flake, and it's also a real-world robustness gap: a healthy webhook that RSTs on close after a valid 202 would be treated as failed.

  • read_status now parses what already arrived when a read errors: if a terminated status line is present the delivery succeeded, so return it; only propagate the error when no status was read.
  • New parse_status_line requires a line terminator, so a truncated first line is never misread as a status code (the success path is otherwise byte-identical to before).
  • The test server half-closes (shutdown(Write)) and drains before drop, so the client reads the full response before the socket closes — preventing the RST at the source too.
  • Adds unit coverage for both the reset-after-response (→ 202) and reset-with-no-status (→ error) paths.

Local: webhook tests 20/20 stable on repeat; fmt/clippy clean (only pre-existing vendored libsql warnings).

Not included (deliberately)

  • install-action bash-startup is a GitHub Windows runner-image bug (actions/partner-runner-images#169) in a uses: step, not our code. There's no clean per-step retry for a uses: step, and a hand-rolled Windows installer can't be validated locally — so it belongs in a separate, infra-focused change (pin/retry the runner) rather than a fragile edit here.
  • No speculative changes to the 29 test sleeps that show no evidence of flaking — that would be churn against the repo's retries = 0 / flaky-result = "fail" "surface flakes, don't mask them" policy.

🤖 Generated with Claude Code

`read_status` failed the delivery on any read error, so a server that
sent its complete HTTP response and then closed abruptly — e.g. a Windows
peer resetting the socket (os error 10053) right after `write_all` —
surfaced as "failed to read webhook response" even though the status had
already arrived. This flaked `webhook_http_post_uses_validated_socket_addr`
on Windows CI.

Parse whatever arrived when a read errors: if a terminated status line is
already present the delivery succeeded, so return it; only propagate the
error when no status was read. `parse_status_line` requires a line
terminator so a truncated first line is never misread as a status. The
test server now half-closes (`shutdown(Write)`) and drains before drop so
the client reads the full response before the socket closes.

Adds unit coverage for both the reset-after-response and reset-with-no-
status paths.

Co-Authored-By: Claude <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b673d2e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@ScriptedAlchemy
ScriptedAlchemy merged commit 604115c into master Jul 3, 2026
7 of 8 checks passed
ScriptedAlchemy added a commit that referenced this pull request Jul 3, 2026
The webhook-reset fix (#259) landed test code that trips the workspace
clippy denials: an unwrap_used in the reset-after-response test and a
map_unwrap_or in the drain loop. Every PR's Clippy job now fails on
master's code. Replace the unwrap with an explicit match/panic and the
map/unwrap_or with is_ok_and.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy deleted the perf/deflake-slow-tests branch July 4, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant