fix(server): preserve self binding in heartbeat timer disconnect#305
Merged
nickjvandyke merged 1 commit intoJun 26, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Neovim/Lua method-binding bug in Server:connect() where the heartbeat timer callback previously passed self.disconnect as a bare function reference, causing the method to be invoked without the correct self receiver when the timer fired.
Changes:
- Wrap the heartbeat timer disconnect callback in a closure so it calls
self:disconnect()with the correct receiver. - Reformat the
uv_timer:start(...)call for readability while applying the fix.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
Ope thank you! I noticed this error occasionally but presumed it'd be complicated and didn't have time to investigate. |
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.
Tasks
Description
Fixed a bug in
Server:connect()where the heartbeat timer callbackself.disconnectwas passed as a bare function reference, losing the implicitselfreceiver. When the timer fired, it would attempt to calldisconnect()without the correctselfcontext, causing a runtime error.How to reproduce
pkill -STOP opencodeselfis nilpkill -CONT opencodeThe fix wraps the callback in a closure to preserve the
selfbinding:Testing
:checkhealth opencodepassesRelated Issue(s)
Screenshots/Videos
N/A