# linux: Fix Wayland clipboard reads blocking indefinitely \(\#58826\) · gitcafe/zed

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

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

Visibility: public

Requested revision: bda5ac3626c6160681cc4100560ed0e0323e4ec3

Requested commit: bda5ac3626c6160681cc4100560ed0e0323e4ec3

Commit: bda5ac3626c6160681cc4100560ed0e0323e4ec3

Tree: fe97069b22e9812a206da4af390798ba99332086

Author: Smit Barmase

Committer: GitHub

## Message

```
linux: Fix Wayland clipboard reads blocking indefinitely (#58826)

Closes FR-44

Unlike X11, where Zed already times out clipboard reads, on Wayland we
had no timeout at all. We read the clipboard from a pipe the source app
writes into, and we were doing a blocking `read_to_end` on it. So if the
other app opened the pipe but never wrote anything, or stalled partway
through, the read would block forever and hang Zed.

This PR replaces it with a non-blocking read driven by `poll` with a 4s
timeout, so:

- a stalled writer fails cleanly instead of freezing us.
- a slow writer that's still making progress on a large payload keeps
working.

This roughly mirrors what the X11 path already does. I have tested
pasting text, large image, drag-n-drop, etc cases.

To Reproduce:

1. Copy text from a web page in Firefox.
2. `kill -STOP "$(pgrep -o firefox)"`
3. Paste into Zed.

Zed hangs indefinitely.

<img width="400"
src="https://github.com/user-attachments/assets/532d1c55-1500-4143-8227-127e0024efba"
/>


Release Notes:

- Fixed a freeze on Linux Wayland when reading the clipboard from a slow
or unresponsive application.
```

## Parents

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

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