Wait for the kept ports to free before the live-prototype server restarts

Open
#18,551 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
devtools

Research direction

Start with cmd_restart in plugins/planning/shared/share.py (around lines 675-689), where stop_server is followed immediately by start_server on the kept ports, then read bridge.port_free and the ensure-running check near lines 566-577 for the existing pattern. Reproduce by running test_a_restart_keeps_a_running_live_prototype in plugins/planning/shared/tests/test_share.py repeatedly. Done means restart waits on a bounded timeout for both ports to free, refuses with a message naming a still-busy port, and two new tests cover the wait and the refusal.

Written by the indexing model from the issue text.

Description

Problem

plugins/planning/shared/tests/test_share.py::TestLives::test_a_restart_keeps_a_running_live_prototype failed in CI with the server did not start: cannot start: [Errno 98] Address already in use (test_share.py:1388), in Test Python (0), job 137962517716. It passes locally (113 passed). The failing PR's diff does not touch the planning plugin.

cmd_restart (plugins/planning/shared/share.py:675-689) calls stop_server(d, s) and then, straight away, start_server(d, ports.get("guest", 0), ports.get("control", s["port"])) on the same ports. If the stopped server has not released its sockets yet, the bind fails. ensure-running (share.py:566-577) checks bridge.port_free before reusing a port. Restart cannot move to a new port the same way, because a named tunnel's ingress rule points at the guest port.

Done when

  • After stop_server, cmd_restart waits until both kept ports are free (bridge.port_free), with a bounded timeout. If a port is still busy after the timeout, it refuses with a clear message naming the port.
  • A test holds the old port open briefly after stop and shows that restart waits and then binds the same ports, and a second test shows the refusal when the port stays busy.
  • test_a_restart_keeps_a_running_live_prototype passes 20 consecutive runs locally (python3 -m pytest -q -k test_a_restart_keeps_a_running_live_prototype --count=20 or a loop).
Dominant language
Shell
Stars
22
Forks
2
Avg merge
2h
Merged PRs (30d)
960

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from melodic-software/claude-code-plugins

All issues in melodic-software/claude-code-plugins

Similar issues

More Shell/Bash issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.