rails / web-console

Rails Console on the Browser.
MIT License
1.39k stars 175 forks source link

Support for multiple web workers (websockets?) #315

Open TSMMark opened 2 years ago

TSMMark commented 2 years ago

Hi, thanks for this gem!

I'm wondering if it's possible for this gem to work with a multi-worker / load balanced architecture such as unicorn. I know the docs here say to just change the number workers to 1 — but that is not always feasible.

To my understanding, the main reason multiple-worker architecture poses an issue is because the repl session is stored in web worker memory on the server, which is only an issue because each HTTP request can be load-balanced to any worker, and that worker may or may not be the worker that had the repl session in memory.

Couldn't that issue be solved with websockets? I feel like this is kind of an obvious solution so I'm assuming there are some gotchas that I haven't thought of. Or if you are aware of any similar web console gems that work with multi-worker or use websockets I would love to check them out, please let me know.

gsamokovarov commented 2 years ago

You want to debug the process that raised the error and this is tricky in multi-process environment, because we cannot be sure the process processing the input of Web Console is the same as the one that produced the error. The same will be the case with Web Console unless the WS server runs inside the same process. The WS server can very well live in a separate process even in development and with WS, we'll have to depend on the app running Web Console to support that server. I don't think it's good to spend developer's time on setting up infrastructure just to run web-console, and requiring it will force people out of using Web Console, in my opinion.

Web Console is a development tool intended to be run on development servers. I don't think solving the "run the Ruby code on that specific Ruby process in any Rack compatible server" problem is a good return on investment. I don't see many issues about it. If you wanna spend time on Web Console – doing UX work will have greater impact.

The frontend code is heavily neglected, it runs on Action View templates, which is ineffective and the UX itself needs a bit of loving so it looks and feels good for the standards of the modern web.

TSMMark commented 2 years ago

I'm mostly interested in the console or <% console %> functionality more-so than the "console when an error is raised" bit. I use better_errors for that anyway.

The kind of thing I am interested in is a ruby repl that runs in browser that can run commands on the back end — regardless of any error context, and regardless of how many web workers there are. Does that make sense?