fix: close lock file handles to prevent leaks#225
Merged
Conversation
hound672
previously approved these changes
May 16, 2026
Contributor
Author
|
@hound672 I should also fix the test for Windows in this pr? |
There was a problem hiding this comment.
Pull request overview
This PR fixes resource-handling issues in the adapters layer by ensuring file and gRPC connection handles are properly closed, and by returning previously ignored write errors to callers.
Changes:
- Close the gRPC client connection exactly once in
RemotePluginExecutor.Execute, preserving close diagnostics without double-closing. - Ensure
LockFile.Newcloses the lock file after reading. - Ensure
LockFile.Writecloses the created file and returnsWrite/Closeerrors instead of discarding them.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/adapters/plugin/remote.go | Replace plain defer conn.Close() + explicit close with a single deferred close that logs close errors. |
| internal/adapters/lock_file/write.go | Add deferred Close() (propagating close errors) and return fp.Write errors instead of ignoring them. |
| internal/adapters/lock_file/lock_file.go | Add deferred Close() for the lock file reader to prevent descriptor leaks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Author
hound672
approved these changes
May 17, 2026
Yakwilik
approved these changes
May 17, 2026
Contributor
Author
|
@Yakwilik can u merge? |
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.
Fixed a few small bugs found while reading the code.
LockFile.NewandLockFile.Writeopened the lock file but never closed it,leaking the handle every time those paths ran.
LockFile.Writealso silentlydiscarded
fp.Writeerrors now they are returned to the caller.RemotePluginExecutor.Executeclosed the gRPC connection twice once viadefer conn.Close()and once explicitly at the end of the function. Thesecond close (the deferred one) silently returned an "already closed" error.
Removed the explicit close and moved the error log into the defer, so the
diagnostic is preserved without double-closing.
Note:
TestCore_BreakingCheck/brokenfails on Windows onmaintoo due toCRLF line endings shifting hardcoded byte offsets in test expectations.
Unrelated to this PR. Linux CI should be green.