rustdesk/rustdesk · warning
Failed to empty clipboard files for conn_id {}
Error message
Failed to empty clipboard files for conn_id {} What it means
After asking the server-side file clipboard context to empty the files for a connection, it reports empty_clipboard(conn_id) == false, meaning the per-connection file clipboard data could not be cleared for that conn_id. The library bails so the caller knows cleanup did not take effect.
Source
Thrown at src/clipboard.rs:212
}
}
}
#[allow(unused_mut)]
if let Some(mut ctx) = ctx.as_mut() {
#[cfg(target_os = "linux")]
{
use clipboard::platform::unix;
if unix::fuse::empty_local_files(_side == ClipboardSide::Client, _conn_id) {
ctx.try_empty_clipboard_files(_side);
}
}
#[cfg(target_os = "macos")]
{
ctx.try_empty_clipboard_files(_side);
// No need to make sure the context is enabled.
clipboard::ContextSend::proc(|context| -> ResultType<()> {
if !context.empty_clipboard(_conn_id)? {
bail!("Failed to empty clipboard files for conn_id {}", _conn_id);
}
Ok(())
})?;
}
}
Ok(())
}
#[cfg(target_os = "windows")]
pub fn try_empty_clipboard_files(side: ClipboardSide, conn_id: i32) {
log::debug!("try to empty {} cliprdr for conn_id {}", side, conn_id);
let _ = clipboard::ContextSend::proc(|context| -> ResultType<()> {
context.empty_clipboard(conn_id)?;
Ok(())
});
}
#[cfg(target_os = "windows")]View on GitHub (pinned to 91c9fccbb0)
Solutions
- Guard against duplicate cleanup — skip if the connection was already marked cleaned.
- Treat a false return during disconnect as non-fatal: log a warning instead of propagating the error.
- Verify conn_id passed in matches the active connection (no stale id from a closed session).
Example fix
// before
try_empty_clipboard_files(conn_id, side)?;
// after: cleanup is best-effort
if let Err(e) = try_empty_clipboard_files(conn_id, side) {
log::warn!("empty clipboard files: {:?}", e);
} Defensive patterns
Strategy: try-catch
Try / catch
if let Err(e) = try_empty_clipboard_files(conn_id, side) {
log::warn!("empty clipboard files for conn {}: {}", conn_id, e);
} Prevention
- Track which connections have already been cleaned to avoid double-empty
- Validate conn_id is still active before cleanup
- Treat teardown-time clipboard errors as warnings, not failures
When it happens
Trigger: try_empty_clipboard_files for a _conn_id whose file clipboard entry no longer exists or was already cleared — ContextSend::proc finds a live context but empty_clipboard returns false for the given connection id (double cleanup, unknown conn_id, or state mismatch).
Common situations: Calling empty twice for the same connection (both disconnect paths racing); conn_id already invalid because the peer disconnected concurrently; macOS server-side file clipboard state removed by another path before this call.
Related errors
- invalid file name {}
- file handle not found
- file handle is not opened
- failed to get general pasteboard
- The printer is installed on the port. Please remove the prin
AI-assisted analysis of rustdesk/rustdesk@91c9fccbb0 (2026-09-10).
Data as JSON: /api/errors/90324b689b1b2c74.
Report an issue: GitHub.