Skip to content

test(register-hook): take ports from the kernel instead of picking one at random - #129

Merged
bompus merged 1 commit into
mainfrom
test/register-hook-port-zero
Oct 10, 2026
Merged

bompus merged 1 commit into
mainfrom
test/register-hook-port-zero

Conversation

@bompus

@bompus bompus commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Two register-hook tests picked a random port in 20000-40000 and started a server there. A busy port failed the run with EADDRINUSE, which happened once on PR #128's first CI run (the rerun passed).

Those two tests now bind port 0 and read the assigned port. The test that must start its server after a first failed attempt asks the kernel for a free port before it starts.

Checked: bun test test/register-hook.test.js three times (28 pass each) and bun run check.

Summary by CodeRabbit

  • Tests
    • Updated test server setup to use operating-system-assigned ports, reducing reliance on randomly selected ports.

…e at random

Two tests picked a random port in 20000-40000 and started a server there, so a busy port failed the run with EADDRINUSE (seen on PR #128's first CI run). They now bind port 0; the test that starts its server late asks the kernel for a free port first.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 316c89ac-4f86-4c40-a820-1b94984e03e4

📥 Commits

Reviewing files that changed from the base of the PR and between 5356317 and 21e46ec.


📒 Files selected for processing (1)
  • test/register-hook.test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.



📝 Walkthrough

Walkthrough

The register-hook tests now obtain ports from the operating system for the retry, headless, and session-start test cases.

Changes

Test port allocation

Layer / File(s) Summary
Port setup in register-hook tests
test/register-hook.test.js
A new freePort() helper starts a temporary server on port 0, stops it, and returns its assigned port. The retry test uses that port. The headless and session-start tests start servers on port 0 and use each running server’s assigned port.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 21e46

The port-allocation changes do not introduce an actionable test failure: the retry test retains a pre-existing collision window, while the other changed tests use their servers’ assigned ports and clean up. No merge-blocking risk remains.

Pre-merge checks | Passed 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: tests now obtain ports from the kernel instead of selecting random ports.
Description check Passed The description explains the failure cause, the implementation change, and the validation performed. The changelog requirement is not applicable because this pull request changes tests only.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Suppressions Explained Passed PASS. The pull request changes only test/register-hook.test.js. Added lines define freePort() and replace random port selection with kernel-assigned ports. No lint, type-check, formatter, or confi…
Interface Changes Documented Passed The pull request changes only test/register-hook.test.js. It adds freePort() and changes test server ports from random values to kernel-assigned ports. It does not add, remove, or rename an MCP to…

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@bompus
bompus merged commit 102caab into main Oct 10, 2026
3 checks passed
@bompus
bompus deleted the test/register-hook-port-zero branch October 10, 2026 03:21
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.

1 participant