Skip to content

test: keep TestCommandHelper fixtures intact for parallel subtests - #465

Merged
alnr merged 1 commit into
masterfrom
alnr/fix-shared-browser-race
Nov 4, 2026
Merged

alnr merged 1 commit into
masterfrom
alnr/fix-shared-browser-race

Conversation

@alnr

@alnr alnr commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

master CI failed after #464 in TestCommandHelper/func=ListProjects (run): its browser login died with target closed: Target page, context or browser has been closed. Staging did not reject anything; the browser was closed while the login was still running.

Two parallel subtests share one Playwright browser. func=Authenticate called cleanup() as soon as its own login finished, which closes the page, the browser and Playwright, while func=ListProjects could still be logging in through that browser. This race has existed since 2024; the identifier-first console login from #464 makes the first login in ListProjects take an extra step, while the session reconfirmation in Authenticate still takes one, so Authenticate now tends to finish first. The browser is now only closed by the parent's t.Cleanup, which runs after all subtests have finished.

While looking for similar problems across the cloudx tests, I found one more in the same test: func=SelectProjectWorkspace changed the selected project and workspace in the config file shared by all subtests, which func=CreateProject copies in parallel and could read half-written or with the other selection. It now works on a copy, like func=CreateProject already does.

Related Issue or Design Document

Follow-up to #464; fixes the master CI failure linked above.

Checklist

  • I have read the contributing guidelines
    and signed the CLA.
  • I have referenced an issue containing the design document if my change
    introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security
    vulnerability. If this pull request addresses a security vulnerability, I
    confirm that I got approval (please contact
    security@ory.com) from the maintainers to push
    the changes.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added the necessary documentation within the code base (if
    appropriate).

Further comments

  • go test -race -count=1 -run '^TestCommandHelper$' ./cmd/cloudx/client/ passes against staging. A single pass cannot prove a race is gone; the argument is that nothing closes the browser before t.Cleanup anymore. In that run ListProjects was still logging in after Authenticate had finished its login, so the old code would have failed it.
  • Checked the other cloudx packages for parallel tests that close or write shared fixtures (defaultConfig, defaultProject, extraProject, the browser) and found none: tests that write project configuration already use their own project, config-changing tests use a copy, and the tests that assert exact list contents either own their project or are its only writer.
  • Left as is: func=UpdateProject replaces the configuration of the shared defaultProject while parallel siblings use that project, but they only assert on its ID and on empty identity, client and relation tuple lists, which a configuration change does not affect. Giving it its own project would add a workspace and a project to every run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DUBUDsgicGQri3GxrTV8VW

func=Authenticate closed the shared Playwright browser as soon as its
own login finished, while func=ListProjects, running in parallel, could
still be logging in through it, which then failed with "target closed".
The browser is now only closed by the parent's t.Cleanup, after all
subtests have finished.

func=SelectProjectWorkspace changed the project and workspace selected
in the shared config file, which func=CreateProject copies in parallel.
It now works on a copy of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DUBUDsgicGQri3GxrTV8VW
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1662a5ba-c5f9-4493-9c7a-291d4ef29b28
Commits

Reviewing files that changed from the base of the PR and between c77d5d1 and e93a4a7.

Files selected for processing: 1
  • cmd/cloudx/client/command_helper_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@alnr
alnr merged commit 1909f84 into master Nov 4, 2026
21 checks passed
@alnr
alnr deleted the alnr/fix-shared-browser-race branch November 4, 2026 17:57
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