Skip to content

linux: Fix Wayland clipboard reads blocking indefinitely - #58826

Merged
smitbarmase merged 1 commit into
mainfrom
fix-wayland-read-clipboard-block
Jun 8, 2026
Merged

linux: Fix Wayland clipboard reads blocking indefinitely#58826
smitbarmase merged 1 commit into
mainfrom
fix-wayland-read-clipboard-block

Conversation

@smitbarmase

@smitbarmase smitbarmase commented Jun 8, 2026

Copy link
Copy Markdown
Member

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.

Release Notes:

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

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 8, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 8, 2026
@smitbarmase
smitbarmase requested a review from probably-neb June 8, 2026 12:19
@smitbarmase
smitbarmase added this pull request to the merge queue Jun 8, 2026
Merged via the queue into main with commit bda5ac3 Jun 8, 2026
52 checks passed
@smitbarmase
smitbarmase deleted the fix-wayland-read-clipboard-block branch June 8, 2026 12:25
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 8, 2026
…ies#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.
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…ies#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.
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ies#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants