Repository navigation
fix(node): close partial listeners on startRPC failure - #5869
Conversation
|
@greptile review |
Greptile SummaryThis PR fixes a file descriptor leak in
Confidence Score: 5/5Safe to merge — the fix is a well-scoped addition of a deferred cleanup that does not affect the success path. The ok-flag pattern correctly gates cleanup on failure. The deferred closure captures listeners by variable reference, so it sees the gRPC listener even if append allocates a new backing array. The test meaningfully validates cleanup by re-binding the freed port, not just asserting an error was returned. No existing behaviour on the success path is altered. No files require special attention. Important Files Changed
|
aljo242
left a comment
There was a problem hiding this comment.
Thanks for the fix here. I have one merge-blocking concern on the test coverage for the cleanup behavior.
TestStartRPCCleansUpOnFailure currently only asserts that startRPC() returns an error. That outcome happens regardless of whether partial listeners are actually cleaned up, so the test doesn't prove the cleanup path and won't catch a regression that leaks the first listener.
Can we strengthen the test to verify cleanup explicitly (e.g., capture the first bound ephemeral port and assert it can be rebound after startRPC() fails)?
|
Non-blocking changelog style nit: the entry currently uses commit-prefix prose ( For consistency with surrounding entries, please use plain descriptive wording after the module tag (e.g. |
aljo242
left a comment
There was a problem hiding this comment.
Re-reviewed latest updates and re-ran local stress on the cleanup test:
go test ./node -run TestStartRPCCleansUpOnFailure -count=20
Passes, and the test now explicitly validates that the first listener is reclaimable after failure.
--- If `startRPC` opened some listeners before a later Listen call failed, those listeners were leaked. Fix by deferring cleanup behind a success flag. #### PR checklist - [x] Tests written/updated - [x] Changelog entry added in `CHANGELOG.md` - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments
If
startRPCopened some listeners before a later Listen call failed,those listeners were leaked. Fix by deferring cleanup behind a success
flag.
PR checklist
CHANGELOG.mddocs/orspec/) and code comments