Skip to content

test(stack): fix 1 flaky test in effect.integration - #7830

Open
avallete wants to merge 1 commit into
developfrom
avallete/flaky-fixes-2026-11-26
Open

avallete wants to merge 1 commit into
developfrom
avallete/flaky-fixes-2026-11-26

Conversation

@avallete

Copy link
Copy Markdown
Member

TL;DR

Hold the conflicting port in the replan-conflict test from a range the test owns, not from the OS ephemeral range.

  • effect.integration.test.ts › fails a start whose requested fixed port is taken, keeping the requested intent saved: the restart after freeing the port sometimes failed with Cannot bind api at 127.0.0.1:<port>: … Is port <port> in use?. The test bound listen(0), so the port came from the OS ephemeral range. It then released that port and restarted rest on it, and another parallel test or outbound socket could take it in between. The holder now binds FIXED_API_PORT + 2, which sits below the stack's automatic range and every ephemeral range, like the sibling tests' fixed ports.

ref

spotted in: https://github.com/supabase/cli/actions/runs/45586961422/job/139110897914


Generated by Claude Code

The replan-conflict test released an OS ephemeral port and then restarted
rest on it, so another parallel test or outbound socket could take it in
between. Bind a fixed port below the auto and ephemeral ranges instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MBEk1NPzAvnzR5sjBpqm6p
@avallete
avallete requested a review from a team as a code owner November 26, 2026 07:39
@avallete
avallete requested a review from Prashansa-K November 26, 2026 07:39

Copy link
Copy Markdown
Member Author

/ai-review


Generated by Claude Code

@avallete avallete added the run-flaky-check Run the flaky-test check on this PR label Nov 26, 2026 — with Claude
@github-actions github-actions Bot removed the run-flaky-check Run the flaky-test check on this PR label Nov 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit a1e6da2 against develop at eee105a · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 201 ms 193 ms no real change
supabase --help help 190 ms 193 ms no real change
supabase init init 192 ms 195 ms no real change
supabase migration new bench migration-new 200 ms 199 ms no real change
supabase config convert config-convert 203 ms 205 ms no real change
supabase config validate config-validate 181 ms 183 ms no real change
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 192 ms 194 ms no real change
supabase projects list projects-list 174 ms 172 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 177 ms 177 ms no real change

API calls: unchanged for all 9 commands.

Binary size: 135.7 MB, unchanged.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 186-217 ms 188-216 ms -8 ms (-4%) within noise
supabase --help help 184-202 ms 187-218 ms +3 ms (+2%) within noise
supabase init init 187-204 ms 187-219 ms +3 ms (+2%) within noise
supabase migration new bench migration-new 192-214 ms 192-223 ms -1 ms (0%) within noise
supabase config convert config-convert 198-224 ms 195-208 ms +2 ms (+1%) within noise
supabase config validate config-validate 176-204 ms 177-219 ms +2 ms (+1%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 184-199 ms 186-236 ms +1 ms (+1%) within noise
supabase projects list projects-list 168-181 ms 170-184 ms -1 ms (-1%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 174-188 ms 173-179 ms 0 ms (0%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by a newer AI review

🤖 AI Review

CLI reference prose guidance: not applicable (no reference sources changed).

The PR avoids reusing an OS-assigned ephemeral port in the stack restart test. One minor test-isolation issue remains: an existing listener on TCP 9395 can fail fixture setup before the test checks how the stack handles a port conflict. The diff changes only test code, so CLI reference prose review was inapplicable.

Findings

Severity Location Category Sources Claim
🟡 MINOR packages/stack/src/effect.integration.test.ts:1774 test-isolation codex An unrelated listener on TCP 9395 can fail fixture setup before the test attempts the stack start that should report the port conflict.

Stats

Claude findings: 0 · Codex findings: 1 · Confirmed: 1 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: manual · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment on lines +1774 to +1775
const conflictingPort = FIXED_API_PORT + 2;
const holder = yield* holdPort(conflictingPort);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MINOR · test-isolation · source: codex

An unrelated listener on TCP 9395 can fail fixture setup before the test attempts the stack start that should report the port conflict.

Evidence: Lines 1774–1775 immediately acquire a listener on FIXED_API_PORT + 2 (9395). Lines 1733–1736 bind that exact loopback port and propagate bind errors. The stack start under test begins at line 1781.

Suggested fix: Try binding candidates in a test-owned range below the ephemeral range and advance to another candidate on EADDRINUSE. Keep a separate test-only lease through the stack's rebind to coordinate concurrent test runs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rests on the same assumption as the file's existing FIXED_API_PORT (9393), which its sibling tests already bind directly. 9395 sits below the stack's automatic range (20000+) and every OS ephemeral range, so neither the stack's own allocations nor outbound sockets can take it. No other test in the repo uses 9395: the only other fixed port nearby is FIXED_STUDIO_PORT 9391. Tests in this file also run one after another. A fixed bind failing on EADDRINUSE would mean a foreign process on a CI runner, and the error would name it. A candidate scan plus a cross-run lease would add machinery that nothing needs yet, so I'm keeping the fixed port.


Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

CLI reference prose guidance: not applicable (no reference sources changed).

One minor test-isolation finding is confirmed. The conflict fixture now requires loopback port 9395 to be free before it can exercise the stack’s port-conflict handling. The diff changes only an integration test, so CLI reference prose review was inapplicable. Verification used source inspection.

Findings

Severity Location Category Sources Claim
🟡 MINOR packages/stack/src/effect.integration.test.ts:1774 test-isolation codex An existing listener on loopback port 9395 makes the integration test fail during fixture setup, before it exercises the stack’s port-conflict handling.

Stats

Claude findings: 0 · Codex findings: 1 · Confirmed: 1 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment on lines +1774 to +1775
const conflictingPort = FIXED_API_PORT + 2;
const holder = yield* holdPort(conflictingPort);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MINOR · test-isolation · source: codex

An existing listener on loopback port 9395 makes the integration test fail during fixture setup, before it exercises the stack’s port-conflict handling.

Evidence: packages/stack/src/effect.integration.test.ts:51 defines FIXED_API_PORT as 9393. Lines 1774–1775 add 2 and bind the resulting port through holdPort. Lines 1735–1736 propagate the listener’s bind error as an Effect failure, so an EADDRINUSE exits setup before the open call at line 1781. The previous helper used listen(0), letting the OS select an available port for the fixture.

Suggested fix: Try a bounded set of ports outside the stack’s automatic and OS ephemeral ranges. Retry the actual bind on EADDRINUSE, then keep the successful listener open until the test deliberately releases it for restart.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same finding as #7830 (comment). The fixed port follows the file's existing FIXED_API_PORT convention: it sits below the auto and ephemeral ranges, and nothing else uses it. A bounded retry scan would still have to release the port before the restart, which is the window this PR closes.


Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Flaky test check: ✅ no flaky tests

Commit f98127234c71 · focused ×10 (5 executions each), 44 tests · integration ×10, 7547 tests · unit ×10, 10112 tests · workflow run

Each execution is a separate Vitest process; Where lists failing runs, as run.iteration for suites executed more than once per run. The full data is in the flaky-check-report artifact.

This branch has not been deployed

No deployments
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