Skip to content
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

stdio repl handling of both stderr and stdout for a form can be a problem sometimes #546

Open
sogaiu opened this issue Dec 17, 2023 · 9 comments

Comments

@sogaiu
Copy link

sogaiu commented Dec 17, 2023

If using Janet's stdio repl [1], evaluating the following form leads to on-stray-output being called sometimes:

(do                                                     
  (print "out")
  (error "err"))

IIUC, this occurs because a callback (cb) gets cleared here as a result of on-stdout triggering before on-stderr (and they both call on-message).

By the time on-stderr gets called, cb ends up being bound to on-stray-output because of this.

In my limited testing at the command line (evaluating the same form), stdout output appears to complete after stderr output which is the reverse order of the callbacks being called. I suppose it's possible that that's just the way it could end up being when using event-based things like libuv?


[1] Possibly this may be an issue for other languages too as relevant code lives in fnl/conjure/remote/stdio.fnl.

@russtoku
Copy link
Contributor

russtoku commented Apr 1, 2024

If you're up to modifying the Janet client code, you could try replacing:

stdio conjure.remote.stdio

with:

stdio conjure.remote.stdio-rt

Please see:

(eval-str (a.assoc opts :code (a.slurp opts.file-path))))

for how things are handled in the SQL client. This might work with a Janet REPL.

This is suggested as a simple work-around for handling other stdio clients. When @Olical completes his modularisation work (#500), hopefully, we can improve how the various REPLs work with Conjure.

@sogaiu
Copy link
Author

sogaiu commented Jul 6, 2024

@russtoku Sorry, for the late response and thanks for these tips!

I had started thinking about doing something like unrepl, i.e. an upgradeable repl, and coincidentally, someone pointed out @andreyorst's fennel-proto-repl-protocol idea. May be you're familiar with it already [1]?

I don't know what the status of that is, but it (or some of the contained ideas) seemed worth considering.

Didn't know about #500 -- will see what I can make of it (^^;


[1] Here are a couple of related blog posts for future readers :)

@russtoku
Copy link
Contributor

russtoku commented Jul 6, 2024

@sogaiu Thanks for sharing! I wasn't aware of fennel-proto-repl. Excellent posts!

I have attempted to diagram some of the REPL interaction in Conjure. Unfortunately, I'm still very much in the dark about things.

@andreyorst
Copy link

andreyorst commented Jul 7, 2024 via email

@sogaiu
Copy link
Author

sogaiu commented Jul 8, 2024

@russtoku I'm probably much more in the dark than you about conjure's workings. Are any of the diagrams you hinted at available for viewing somewhere?

@sogaiu
Copy link
Author

sogaiu commented Jul 8, 2024

@andreyorst Thanks for chiming in -- perhaps I should have searched the discussions first (^^;

Regarding "already one neovim client", may be you meant this repository?

@andreyorst
Copy link

andreyorst commented Jul 8, 2024 via email

@russtoku
Copy link
Contributor

@russtoku I'm probably much more in the dark than you about conjure's workings. Are any of the diagrams you hinted at available for viewing somewhere?

Sorry, I replied in Discord instead of here so just pasting in my replies from Discord.

In my frustration, I sent them to the trash.

I did keep some notes on the ways that Neovim plugins send stuff to a sub-process. https://russtoku.github.io/posts/nvim-and-repls.html

@andreyorst
Copy link

andreyorst commented Aug 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants