# Fix ACP connection and thread leak \(\#35670\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/b7469f5bc346ca9723a3595f6f00c5fe6a3f7a6c)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: b7469f5bc346ca9723a3595f6f00c5fe6a3f7a6c

Requested commit: b7469f5bc346ca9723a3595f6f00c5fe6a3f7a6c

Commit: b7469f5bc346ca9723a3595f6f00c5fe6a3f7a6c

Tree: b85571367f336eb80e59c84d73186394cfdd9386

Author: Agus Zubiaga

Committer: GitHub

## Message

```
Fix ACP connection and thread leak (#35670)

When you switched away from an ACP thread, the `AcpThreadView` entity
(and thus thread, and subprocess) was leaked. This happened because we
were using `cx.processor` for the `list` state callback, which uses a
strong reference.

This PR changes the callback so that it holds a weak reference, and adds
some tests and assertions at various levels to make sure we don't
reintroduce the leak in the future.

Release Notes:

- N/A
```

## Parents

- [f27dc7dec76190862d9c5e2a78371f25c471db54](https://git.cafe/gitcafe/zed/commit/f27dc7dec76190862d9c5e2a78371f25c471db54?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/b7469f5bc346ca9723a3595f6f00c5fe6a3f7a6c?format=markdown)
