Repository navigation
test(broker): accept a refusal that meets a closed socket - #84
Merged
Merged
Conversation
nats.go writes CONNECT and PING in 2 writes. lodge refuses a connection that it cannot name with -ERR 'Authorization Violation' and closes it, so the PING write can fail with EPIPE before the client reads the refusal line. TestDevelopmentUIDNamesItsApp then failed with a broken pipe under load. The test now accepts EPIPE or ECONNRESET as the refusal, and only together with the broker's log line for that refusal. The log check also closes a gap: the NATS server answers its own authorization violation for an account that it lacks, so the old text check passed even when lodge admitted the connection.
Contributor
Author
|
Cross-review record
|
bketelsen
approved these changes
Nov 16, 2026
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.
Summary
TestDevelopmentUIDNamesItsApp(from #81) fails under load withwrite unix ...nats.sock: write: broken pipe, want an authorization violation.It blocks
make check, and somake bump.Cause: nats.go writes
CONNECTandPINGin 2 writes (writeDirect). lodgerefuses a connection that it cannot name: it writes
-ERR 'Authorization Violation'and closes. When the close comes before thePINGwrite, the client fails with EPIPE (or ECONNRESET) and never reads therefusal line. This is the same race as frostyard/hearth#4.
Fix (test only, no product change):
refusedUnnamedaccepts the refusal text, or EPIPE orECONNRESET. It accepts them only when the broker logged
the broker refused a connection: lodge cannot name it. lodge writes thatline before it closes. Any other error, or an admission, still fails.
removed, the NATS server answers its own
Authorization Violationfor anaccount that it lacks, so the old text check still passed.
Other refusal tests in
internal/broker:TestBadTokenIsRefusedandTestConnectNullIsRefused(client door) run overnet.Pipe. A pipe write blocks until the peer reads, andrefusedrainsthe peer's writes, so the refusal line always arrives.
TestConnectNullIsRefused(app socket) sends 1 write and reads therefusal line raw: no second write can meet the closed socket.
TestAppSocketClosesAnUnknownUIDand the revoke tests accept any error.Risk tier
Risk tier: 3, by the
risk:highlabel. Matched path:internal/broker/**(internal/broker/options_test.go). The change is safe:it changes only a test file and adds a correction record. No product code
changes.
Verification
make checkgreen (host).make raceandmake crossgreen (host, inmake ci).make client-check,ui-check,shell-check: not run here.nslfails on the agent host, and this PR changes nothing under
client/,ui/or
shell/. CI runs them.binary (
-test.count=200 -test.cpu 1,2,8) failed many times withbroken pipe.EPIPE path.
go test -race -count=50 ./internal/broker/: ok (274 s).go test -race -count=50:AppEnabledcheck inserveApp's development branch removed:TestDevelopmentUIDNamesItsAppfails 50 of 50 (no refusal logged; theserver answered its own authorization violation).
serveAppremoved:TestAppSocketClosesAnUnknownUIDfails 50 of 50.
.memory/corrections/2026-11-16-pr-84-refusal-tolerates-a-closed-socket.json.