Repository navigation
test(listen): attribute missing binary deliveries and stop one late delivery failing later steps - #483
Merged
Conversation
…elivery failing later steps The binary-body listen tests failed intermittently with "Connected. Waiting for events..." then "no request reached the local app within 45s", which could not say where the event went. Reproduced locally: the event was created for the listening CLI and stayed QUEUED with no delivery attempt for minutes while the CLI's websocket was connected and answering pings. The same stall failed the JSON forwarding test, so it is neither binary-specific nor in the CLI. The harness made it worse: localApp.next took whatever arrived next, so a late delivery failed the following steps with a wrong Content-Type and file. - Wait for listen's "Connected. Waiting for events..." line instead of sleeping 12 seconds. - Tag each send with X-Acceptance-Delivery-Id; each step waits for its own delivery and skips others. - On timeout, look the request and its events up by that header and report event status and attempts, plus the websocket lines from listen's debug log. - Drop the duplicate connection delete that logged a 410 warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the
listenbinary-body acceptance tests (test/acceptance/listen_binary_test.go) report why a delivery did not arrive, and stops one slow delivery from failing the steps after it. Tests only; no CLI code changes.Why
These tests failed in 2 of 14 runs since they landed on 2026-10-02, both with
Connected. Waiting for events...followed byno request reached the local app within 45s:main):TestListenForwardsBinaryFilesThatTheAppCanSave/raw_application/octet-streamTestListenBinaryWithOldAndNewCLIListening/raw_imageand/multipart_uploadThat message could not say where the event went, so the failure could not be attributed.
Root cause
Verified (reproduced locally, 2 failures in 15 looped runs of the
listentests, with debug logging and the API's view of each event):QUEUEDwith 0 attempts for 1 to 3 minutes. Meanwhile the CLI's websocket was connected and answering pings, and received no message. The one event that was eventually attempted was forwarded by the CLI and returned 200. So the delay is upstream of the CLI. It is not in the CLI's forwarding, and it is not a readiness race: the events were sent 11 s after the websocket connected, and sends made immediately after connecting were delivered every time (8 of 8 in a dedicated check, and every such send in the after-fix loop below).TestListenForwardsEventsWithoutTTY, which sends a JSON body. It is not specific to binary bodies, nor to the old-and-new-CLI test. The 2026-10-29 run shows the same thing: that test also timed out within the same three minutes.localApp.nexttook whatever request arrived next. When a delayed event finally arrived, it was taken as the following step's delivery. That step then failed with a wrong Content-Type and a wrong file (reproduced: thejpegstep saved the 256-byte octet-stream body). So one slow delivery failed several steps, with misleading messages.Not the cause:
hookdeck cicreates a distinct CLI client.410 Resource was deletedwarning: listen's cleanup had already deleted the connection, so the test's own delete found nothing. Noise.Inferred, not verified here: why delivery to a connected CLI session stalls for minutes. This has been reported separately; it is not something the tests or the CLI can fix.
Change
Readiness: each test waits for listen's
Connected. Waiting for events...line, which this CLI and v3.0.3 both print, instead of sleeping 12 s. It fails fast if listen exits.Correlation: every request carries a unique
X-Acceptance-Delivery-Idheader. Each step waits for its own delivery and logs and skips any other, so a late delivery can no longer fail the next step.A failure says where the event stopped. On timeout the test looks the request up by that header (
gateway request list --search-term, thengateway event list --search-term) and reports:listen now runs with
--log-level debug. A failure prints its stdout plus only the websocket lines (connect, close, every incoming message), so it shows whether anything reached the session.Cleanup: removed the redundant connection delete that produced the 410 warning.
The binary tests also run faster: 20 s to 9 s, 19 s to 8 s, and 55 s to 30 s.
The change is deliberately not a retry or a longer timeout. A stalled delivery still fails the test, now with a message that attributes it.
Testing
All local acceptance runs were made with no CI acceptance run in progress or queued (checked before each iteration).
go test -short ./pkg/...: exit 0go vet ./...: exit 0ACCEPTANCE_SLICE=2 go test -tags=listen -run '<the three binary tests>|TestListenForwardsEventsWithoutTTY' ./test/acceptance/, looped 15 times: 13 passed, 2 failed. Both failures fell in one stall window: one inTestListenForwardsEventsWithoutTTY, one inTestListenForwardsBinaryFilesThatTheAppCanSave, where a single delayed event failed all five subtests.SUCCESSFUL, 1 attempt), a request with no listener (0 events, 1 ignored), and an unknown id (no request);🤖 Generated with Claude Code