Skip to content

fix(tracing): reuse the dashboard port only when it is our own viewer#141

Merged
0xKT merged 1 commit into
mainfrom
feat/tracing_viewer_port_health
Jul 17, 2026
Merged

fix(tracing): reuse the dashboard port only when it is our own viewer#141
0xKT merged 1 commit into
mainfrom
feat/tracing_viewer_port_health

Conversation

@arelchan

Copy link
Copy Markdown
Contributor

Summary

Harden raven tracing so it never opens the browser onto a "Not found" page.

The launcher treated any listener on the dashboard port as its own running
viewer: _open_dashboard only checked whether the TCP port was live, then
pointed the browser at it. A stale viewer from an older on-disk layout (its
index.html was later replaced by an inlined shell.js) -- or an unrelated
server -- holding that port answered every request with 404 Not found, so
/tracing opened a broken page.

Fix: probe GET /api/health before reusing a live port.

  • Reuse the port only when it answers {"ok": true} (our viewer's signature; a
    foreign or stale server does not).
  • If the port is held by something else, start the viewer on the next free port
    instead of clashing (or error clearly if none is free nearby).
  • Readiness now waits on /api/health succeeding rather than a bare TCP
    connect, so we only open the browser once the viewer actually serves.

Type

  • Fix

Verification

  • Relevant tests pass locally
  • Relevant lint / type checks pass locally

Commands run:

  • uv run pytest tests/test_cli_tracing_commands.py -q -> 4 passed
    (health false when nothing listening / false for a foreign 404 server / true
    for our viewer / free-port scan skips an occupied port).
  • uv run ruff check raven/cli/tracing_commands.py tests/test_cli_tracing_commands.py -> clean.
  • Reproduced the original bug on a real machine: a stale viewer process held
    4318 and returned 404 Not found for /; with this change the launcher
    detects it is not our viewer and moves to a free port.

Risk

  • Security impact considered
  • Backward compatibility considered

Backward-compatible: same behavior when the port is free or already hosts our
viewer; only the "foreign process on the port" case changes (previously a broken
page, now a working viewer on another port). No API or schema change.

Related Issues

N/A -- follow-up hardening on the tracing viewer merged in #135.

`raven tracing` treated any listener on the dashboard port as a running
viewer and pointed the browser at it. A stale viewer from an older layout
(or an unrelated server) holding the port answered every request with 404,
so /tracing opened a "Not found" page. Probe /api/health before reusing:
reuse only when it returns {"ok": true}, otherwise start on the next free
port. Readiness now waits on health rather than a bare TCP connect.

Co-authored-by: Claude (claude-opus-4-8) <noreply@anthropic.com>
@arelchan
arelchan requested a review from 0xKT July 17, 2026 03:56
@0xKT
0xKT merged commit dbb1b0c into main Jul 17, 2026
8 checks passed
@0xKT
0xKT deleted the feat/tracing_viewer_port_health branch July 17, 2026 04:39
@cyfyifanchen cyfyifanchen mentioned this pull request Jul 19, 2026
12 tasks
cyfyifanchen added a commit that referenced this pull request Jul 19, 2026
## Summary

Bump Raven package metadata from 0.1.5 to 0.1.6 so the release tag can
build a wheel from the current main branch.

This release carries the changes merged after v0.1.5:

- Version display now derives from installed package metadata (#139).
- Tracing dashboard port reuse avoids taking over non-Raven viewers
(#141).
- CLI startup defers LiteLLM imports for faster cold start (#147).
- Self-evolution stack and AppWorld benchmark entry points are included
(#140).
- TUI render delay is reduced by deferring provider and memory loading
(#157).

## Type

- [ ] Fix
- [ ] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [x] Other

## Verification

- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed

Commands run:

- `PYTHONPATH=. uv run pytest
tests/test_cli_smoke.py::test_version_flag_matches_installed_metadata
-q`
- `make check-commits COMMIT_RANGE=origin/main..HEAD`
- `PYTHONPATH=. uv run python scripts/check_commit_file.py
/tmp/raven-commit-msg.txt`

No user-facing docs or screenshots were needed for this version metadata
bump; release notes will be published with the GitHub Release.

## Risk

- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes

This changes package metadata only. Rollback is to delete the v0.1.6
tag/release if publication fails before users upgrade, or publish a
follow-up patch release if a released package issue is found.

## Related Issues

N/A
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

Successfully merging this pull request may close these issues.

2 participants