Skip to content

[8.x] Return JSON response from auth endpoints to prevent browser race condition in fast CI environments#1186

Closed
jackbayliss wants to merge 3 commits intolaravel:8.xfrom
jackbayliss:sort-flaky-tests
Closed

[8.x] Return JSON response from auth endpoints to prevent browser race condition in fast CI environments#1186
jackbayliss wants to merge 3 commits intolaravel:8.xfrom
jackbayliss:sort-flaky-tests

Conversation

@jackbayliss
Copy link
Contributor

@jackbayliss jackbayliss commented Feb 24, 2026

When using fast CI runners browser tests can flake because loginAs() and logout() use visit() to hit endpoints that return 204.

The browser receives the 204 but has no page load event to wait for, so the WebDriver considers the navigation complete immediately and fires the next command before the browser has fully processed and stored the session cookie.

Changing the response from 204 to 200 gives the browser a proper response to settle on. It was originally 204 to prevent favicon errors, but by doing json() we ensure the content-type is json - so no favicons requested :)

Here's a real example... (all three are in the same second)

127.0.0.1 - - [24/Feb/2026:21:02:03 +0000] "GET /_dusk/logout HTTP/2.0" 204 1138 "-" "Laravel/Dusk"
127.0.0.1 - - [24/Feb/2026:21:02:03 +0000] "GET /item/1 HTTP/2.0" 302 1477 "-" "Laravel/Dusk"
127.0.0.1 - - [24/Feb/2026:21:02:03 +0000] "GET /login HTTP/2.0" 200 2066 "-" "Laravel/Dusk"

I have an override for this in my project which seems to work..

@github-actions
Copy link

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@jackbayliss jackbayliss marked this pull request as ready for review February 24, 2026 23:13
@jackbayliss jackbayliss marked this pull request as draft February 24, 2026 23:17
@jackbayliss jackbayliss changed the title [8.x] Ensure session is saved on logout [8.x] Return JSON response from auth endpoints to prevent browser race condition in fast CI environments Feb 24, 2026
@jackbayliss
Copy link
Contributor Author

Hm, i'm not sure this is the right thing to do, ive got an override locally, but doesn't seem to related to this.

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