---
title: disconnectHandler
framework: webkit
role: symbol
role_heading: Instance Property
path: webkit/wkwebextension/messageport/disconnecthandler
---

# disconnectHandler

The block to be executed when the port disconnects.

## Declaration

```swift
var disconnectHandler: (((any Error)?) -> Void)? { get set }
```

## Discussion

Discussion An optional block to be invoked when the port disconnects, taking an optional error that indicates if the disconnection was caused by an error.
