## TL;DR

The session ended while commands were still queued: the driver timed out, crashed, or a previous command killed it. Find which command ended the session, fix that, and keep sessions alive for the test duration.

## Error

```text
Error: A session is either terminated or not started
```

## Steps

1. Look at the last command before the failure in the logs. Expected: the session-killer identified.
2. Common killer: a navigation that crashed the tab, or a `browser.close()` in a helper. Fix or remove it. Expected: session survives.
3. Raise driver timeouts if the session idles out during long waits. Expected: no idle timeout.
4. Check for parallel tests sharing one session; give each test its own. Expected: no cross-test kills.
5. Re-run. Expected: session lasts the whole test.

## When to use

- `session deleted` / `terminated` mid-test.
- After crashes or long idle waits.

## When not to use

- Session never starts (launch issue).
- Grid queue timeouts (infrastructure).

## Tool compatibility

- WebdriverIO 8.x; any driver.

## Variant phrasings

### WebdriverIO session terminated

Same event; find the killer command.

### No active session in WebdriverIO

The session ended before the command ran.

## Why it happens

Sessions are stateful and fragile. Anything that kills the browser or times out the driver ends them, and queued commands then fail.

## Edge cases

- `browser.reloadSession()` recovers but loses state; prefer not needing it.
- Mobile sessions are slower to establish; timeouts need raising there first.
- After hooks that close the session can race the last command.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_iVKKpPk_2pQ6UhvAGtymwQ
