Files
Charles Bochet 34c71647bb fix(front): make logout navigate once (unbreaks the invite e2e) (#24128)
## What

Logout performed two navigations to `/welcome`. It now performs one.

This also unbreaks `signup_invite_email`, the last spec failing `CI E2E
Main` on `main` (run
[31687111270](https://github.com/twentyhq/twenty/actions/runs/31687111270),
failed all 3 attempts).

## Why

`clearSession` resets the session atoms and then calls
`window.location.assign(AppPath.SignInUp)`. Clearing the atoms flips the
still-mounted app to logged out, so the redirect effect routes it to
`/welcome` client-side while the browser is still fetching the document
that `assign` asked for. Traced on a production build:

```
=== clicking logout
RESP 200 SignOut errors=false
NAVCALL pushState /welcome     <- react-router, from the redirect effect
COMMITTED /welcome             <- that pushState
COMMITTED /welcome             <- the document load, ~600ms later
```

So the URL reads as arrived at `/welcome` while a full page load is
still in flight, and anything that navigates in that window is
interrupted. The invite spec did exactly that and died with `Navigation
to .../invite/... is interrupted by another navigation to .../welcome`.

`isAppEffectRedirectEnabledState` already exists for this situation and
is used the same way around the verify and SSO flows: a deliberate
navigation is in flight, so the effect must not route. Setting it in
`clearSession` leaves the `assign` as the only navigation. The session
teardown is unchanged — the atoms still get cleared, several of them are
persisted (the token pair, the workspace-domain cookie) and dropping
that would leave the user signed in after the reload.

After the fix, same trace:

```
=== clicking logout
RESP 200 SignOut errors=false
COMMITTED /welcome             <- one navigation
NAVCALL replaceState undefined <- react-router booting in the new document
```

With logout deterministic, the spec just waits for `/welcome` and
navigates; no retry loop.

## Tests

Against a local server serving the front build the way CI does:

- `signup_invite_email` `--repeat-each=5`: 5/5 green. Before the fix it
failed roughly 1 run in 4, and 3/3 on CI.
- Full e2e suite: 9/9 green.
- `useAuth.test.tsx`: 8/8, including `should handle sign-out`, which
asserts the session atoms are cleared.
2026-08-13 14:19:12 +02:00
..