siyuan-note/siyuan · error
open clipboard timeout
Error message
open clipboard timeout
What it means
Returned by waitOpenClipboard after retrying w32.OpenClipboard once per millisecond for up to one second. Windows enforces a single clipboard owner: only one process can hold the clipboard open at a time, so OpenClipboard fails while another app (clipboard viewer, remote-desktop tool, antivirus) has it open.
Source
Thrown at kernel/util/clipboard_windows.go:161
binary.LittleEndian.PutUint16(buf[offset:offset+2], c)
offset += 2
}
}
return buf, nil
}
// waitOpenClipboard 在限定时间内重试打开剪贴板。
// 同一时刻仅一进程可持有剪贴板(OpenClipboard 成功)。
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-openclipboard
func waitOpenClipboard() error {
deadline := time.Now().Add(time.Second)
for time.Now().Before(deadline) {
if w32.OpenClipboard(0) {
return nil
}
time.Sleep(time.Millisecond)
}
return errors.New("open clipboard timeout")
}
View on GitHub (pinned to 251596fc0d)
Solutions
- Close other clipboard-monitoring tools (clipboard managers, RDP clipboard sync, screen-snipping tools) and retry.
- Retry the copy operation — the lock is usually brief and a second attempt shortly after often succeeds.
- If the contention is persistent, raise the retry window or retry at the caller level rather than lengthening the tight loop.
Example fix
// before
if err := util.WriteFilePaths([]string{absPath}); err != nil {
return err
}
// after
var err error
for attempt := 0; attempt < 3; attempt++ {
if err = util.WriteFilePaths([]string{absPath}); err == nil {
break
}
time.Sleep(200 * time.Millisecond)
} Defensive patterns
Strategy: retry
Try / catch
var err error
for attempt := 0; attempt < 3; attempt++ {
if err = util.WriteFilePaths(paths); err == nil || !strings.Contains(err.Error(), "open clipboard timeout") {
break
}
time.Sleep(300 * time.Millisecond)
} Prevention
- Close clipboard-monitoring utilities and RDP clipboard sync before large copy operations.
- Surface 'clipboard busy, retrying' to the user instead of failing on the first timeout.
When it happens
Trigger: Calling WriteFilePaths on Windows while another process holds the clipboard open for longer than 1 second. The 1-second deadline in waitOpenClipboard is exceeded before OpenClipboard succeeds.
Common situations: A clipboard-monitoring utility (e.g. a clipboard manager, snipping tool, or RDP/Teams clip-share) holding the clipboard; antivirus inspecting clipboard contents; rapid repeated copy operations; running under a remote-desktop session that synchronizes the clipboard.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- attribute view [%s] changed while loading search info
- encrypted notebook is locked, please unlock it first
- duplicate inherited variable %q
- duplicate variable %q
- OAuth callback was already handled
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/441794f7afa389c1.
Report an issue: GitHub.