Bazel port blocked causing server crash?

It looks like there is a problem when I use Bazel, or Bazelisk, on replit. The current problem is that the bazel server seems to halt after running a command, so each time I successfully run a command the subsequent commands wont be able to the server.

For example if I run

bazelisk run @//:Main

The first time it will run, after downloading bazel, the dependencies etc. but after that if I make a code change or want to run a different command it, bazelisk, wont be able to connect to the server. It will hang there and I’ll have to Ctr-C a few times to get back to a command prompt. After this if I want to I can run the comman, but it will have to start the server again and connect to it. I can tell this because it says it is starting the server. Also the port it starts on seems to be different.

I suspect this has something to do with networking causing an issue. Perhaps replit blocks the ports that are used by running services during development? GitHub codespaces seems to work, though I see some kind of port forwarding action happening over there, possibly a configuration of the devcontainer or docker. It would be nice to have feature parity hear, at least in the sense of being able to use bazel without restarting the server every other command.

At one point it looked like the server wouldn’t even start, but perhaps there was a change in the underlying infrastructure of replit.

You can find the bazel port with the following command

cat $(bazelisk info output_base)/server/command_port

You can find a working bazel project and run this command in my repels.

It’s still wip (work in progress)