---
title: "extendedRuntimeSession(_:didInvalidateWith:error:)"
framework: watchkit
role: symbol
role_heading: Instance Method
path: "watchkit/wkextendedruntimesessiondelegate/extendedruntimesession(_:didinvalidatewith:error:)"
---

# extendedRuntimeSession(_:didInvalidateWith:error:)

Indicates that the session has encountered an error or stopped running.

## Declaration

```swift
func extendedRuntimeSession(_ extendedRuntimeSession: WKExtendedRuntimeSession, didInvalidateWith reason: WKExtendedRuntimeSessionInvalidationReason, error: (any Error)?)
```

## Parameters

- `extendedRuntimeSession`: The session that became invalid.
- `reason`: The reason the session became invalid.
- `error`: If the reason parameter is doc://com.apple.watchkit/documentation/WatchKit/WKExtendedRuntimeSessionInvalidationReason/error, then this parameter contains additional information about the error. Otherwise it is set to nil.

## Discussion

Discussion The system calls this method both when a session fails to start and when a session stops running. Use the invalidation reason to determine why the session became invalid. important: If your app terminates immediately after the system invalidates the session, you may not receive this delegate call until the user launches your app again. In that case, the system calls your extension delegate’s handle(_:) method to resume the session. Then, after you assign the session delegate, the system finally makes this delegate call.

## See Also

### Monitoring State Changes

- [extendedRuntimeSessionDidStart(_:)](watchkit/wkextendedruntimesessiondelegate/extendedruntimesessiondidstart(_:).md)
- [extendedRuntimeSessionWillExpire(_:)](watchkit/wkextendedruntimesessiondelegate/extendedruntimesessionwillexpire(_:).md)
- [WKExtendedRuntimeSessionInvalidationReason](watchkit/wkextendedruntimesessioninvalidationreason.md)
