-
Couldn't load subscription status.
- Fork 9
Robustness and Efficiency #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for such clearly delineated commits + the thorough description. Very much appreciated.
With this PR, I'm currently seeing an indefinite hang once a tool request is made. When I start the server before the proxy (i.e. mcp_serve() and then launch Claude Desktop), I intermittently see:
Warning: data could not be converted to a character string
<simpleError: parse error: trailing garbage
42 0a 03 00 00 00 00 05 04 00 00 0
(right here) ------^
...in my server R session.
|
Did you install the package (as opposed to load_all) and restart Claude etc.? 😏 That seems to be a mismatch between the server and proxy versions, as I switched from using serialisation to not. |
|
Able to reproduce the issue on |
|
@shikokuchuo I'm curious about the comment about |
As our loops here don't seem to be that tight, just keeping the reference should be safe enough. 100% safe usage would be to wait for the result e.g. by This also means that we can mostly replace with a |
That sounds dangerous. Maybe nanonext should keep references to these objects until the send happens? |
Sorry I should have been clearer - it's not dangerous in the way you're thinking. It implicitly stops the aio safely before deallocation happens, so at worst the send fails. It'd be nice to ensure it completes, but that would involve the finaliser waiting, and I wouldn't want to block the garbage collector. |
|
It still sounds like it could be the source of surprising and hard-to-debug problems -- I have dealt with surprising and random-looking errors related to GC in the past and it is not fun! If someone calls |
|
I hear what you're saying. Previously I'd probably have said 'user error' in not keeping a reference, but I agree that eliminating this potential failure point makes for more robust (and predictable) behaviour. I'm opening a PR at nanonext that amends this, thanks for the suggestion! |
Summarising the changes in this PR:
nanonext::write_stdout()rather thancat()for robustness and efficiency (I happened to implement this a couple of days ago for something else!)send_aio()temporarily assign the aio object to prevent finalisers being run too early (ultimately we may decide to make these synchronous)stdinin blocking mode to avoid the potentially buggy behaviour that @wch found on MacOS. It's safe to do this, as we only read when there's activity detected on the FD. There's possibly a more robust solution doing it from C, which we can substitute in later if we find it.