Skip to content

Build: Use HTTP check instead of detect-port for service readiness to prevent EADDRINUSE#33924

Merged
valentinpalkovic merged 2 commits into
nextfrom
copilot/fix-port-clash-in-ci
Feb 25, 2026
Merged

Build: Use HTTP check instead of detect-port for service readiness to prevent EADDRINUSE#33924
valentinpalkovic merged 2 commits into
nextfrom
copilot/fix-port-clash-in-ci

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 25, 2026

Closes #33650

detect-port can give false negatives in CI container environments — reporting a port as free even when a server is already bound to it (typically due to IPv4/IPv6 interface differences). When this happens during yarn task e2e-tests-dev -s e2e-tests-dev, the dev task gets 'notserving' status, causing the task runner to attempt starting Storybook again, resulting in EADDRINUSE: address already in use 127.0.0.1:6006.

Changes

  • scripts/tasks/dev.ts / scripts/tasks/serve.ts: Replace detect-port TCP check in ready() with an HTTP fetch to /iframe.html. This matches what the CI "wait for port" step does and is immune to the IPv4/IPv6 false-negative issue.
- return (await detectFreePort(port)) !== port;
+ try {
+   await fetch(`http://localhost:${port}/iframe.html`, { signal: AbortSignal.timeout(1000) });
+   return true;
+ } catch {
+   return false;
+ }

The HTTP check verifies Storybook is actually serving content rather than just testing port occupancy, making it a more accurate signal of service readiness.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Summary by CodeRabbit

  • Refactor
    • Updated server readiness detection to use active HTTP endpoint verification instead of port detection, providing more reliable confirmation of server availability during development.

…revent EADDRINUSE

Co-authored-by: valentinpalkovic <5889929+valentinpalkovic@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix port clash issue in CI for E2E tests fix: use HTTP check instead of detect-port for service readiness to prevent EADDRINUSE Feb 25, 2026
@valentinpalkovic valentinpalkovic added build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs). labels Feb 25, 2026
@valentinpalkovic valentinpalkovic changed the title fix: use HTTP check instead of detect-port for service readiness to prevent EADDRINUSE Build: Use HTTP check instead of detect-port for service readiness to prevent EADDRINUSE Feb 25, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Feb 25, 2026

View your CI Pipeline Execution ↗ for commit 810c15c

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ❌ Failed 11m 45s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-25 11:43:20 UTC

@github-actions
Copy link
Copy Markdown
Contributor

Fails
🚫 PR description is missing the mandatory "#### Manual testing" section. Please add it so that reviewers know how to manually test your changes.

Generated by 🚫 dangerJS against 810c15c

@valentinpalkovic valentinpalkovic marked this pull request as ready for review February 25, 2026 15:11
@valentinpalkovic valentinpalkovic merged commit 2a47ef9 into next Feb 25, 2026
126 of 137 checks passed
@valentinpalkovic valentinpalkovic deleted the copilot/fix-port-clash-in-ci branch February 25, 2026 15:12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbca9fc and 810c15c.

📒 Files selected for processing (2)
  • scripts/tasks/dev.ts
  • scripts/tasks/serve.ts

📝 Walkthrough

Walkthrough

Both dev and serve task scripts replaced port availability detection with HTTP probing. The updated ready() function attempts to fetch http://localhost:<port>/iframe.html with a 1-second timeout, returning true on success and false otherwise. The public API remains unchanged.

Changes

Cohort / File(s) Summary
Readiness Check Refactor
scripts/tasks/dev.ts, scripts/tasks/serve.ts
Replaced port detection via detect-port library with HTTP fetch probe to /iframe.html endpoint; added try/catch error handling and 1s timeout to verify server responsiveness instead of port availability.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Internal-facing build tooling & test updates ci:normal Run our default set of CI jobs (choose this for most PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2E: ExecaError: Command failed with exit code 1: 'yarn storybook --port 6006 --ci'

2 participants