---
title: "disconnect(throwing:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebextension/messageport/disconnect(throwing:)"
---

# disconnect(throwing:)

Disconnects the port, terminating all further messages with an optional error.

## Declaration

```swift
func disconnect(throwing error: (any Error)?)
```

## Parameters

- `error`: An optional error indicating the reason for disconnection.
