Skip to content

Conversation

@etraut-openai
Copy link
Collaborator

This PR fixes a test that is sporadically failing in CI.

The problem is that two unit tests (the older login_and_cancel_chatgpt and a recently added login_chatgpt_includes_forced_workspace_query_param) exercise code paths that start the login server. The server binds to a hard-coded localhost port number, so attempts to start more than one server at the same time will fail. If these two tests happen to run concurrently, one of them will fail.

To fix this, I've added a simple mutex. We can use this same mutex for future tests that use the same pattern.

@etraut-openai etraut-openai marked this pull request as ready for review October 24, 2025 22:33
@etraut-openai
Copy link
Collaborator Author

@codex review

@etraut-openai etraut-openai requested a review from gpeal October 24, 2025 22:34
@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 27 to 29
async fn login_test_guard() -> MutexGuard<'static, ()> {
LOGIN_TEST_MUTEX.get_or_init(|| Mutex::new(())).lock().await
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use #[single(login)]

What is the underlying thing that needs to be locked? Is it an env var?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's the login server instance itself. It needs to bind to a specific localhost port, so if you attempt to start two instances concurrently, the second one will fail to bind.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TIL about #[single(x)]. Nice!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use login_port because there are other login tests that could run in parallel

@etraut-openai etraut-openai requested a review from gpeal October 24, 2025 22:48
@etraut-openai etraut-openai merged commit 0533bd2 into main Oct 24, 2025
20 checks passed
@etraut-openai etraut-openai deleted the etraut/flaky_login_test branch October 24, 2025 23:31
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants