openclaw - 💡(How to fix) Fix Windows: Telegram media download fails with EPERM on FileHandle.sync() [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77261Fetched 2026-05-05 05:50:32
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
2
Timeline (top)
closed ×1commented ×1mentioned ×1subscribed ×1

On Windows, inbound Telegram media can fail to download/save with EPERM: operation not permitted, fsync. The bot then sends Failed to download media. Please try again. even though Telegram delivered the file.

Error Message

After sending an image to the Telegram bot, OpenClaw logs:

Root Cause

Expected behavior

Windows should not fail Telegram media ingestion solely because FileHandle.sync() returns EPERM. OpenClaw should either tolerate this Windows-specific sync failure or use a Windows-safe fsync strategy.

Fix Action

Fix / Workaround

Local workaround tested

Catching Windows-only EPERM around handle.sync() allowed media saving to succeed:

After this local patch, the same media save function successfully wrote inbound images to .openclaw/media/inbound.

Code Example

media fetch failed
Error: EPERM: operation not permitted, fsync

---

Failed to download media. Please try again.

---

dist/store-D8lbL3Fm.js
writeSavedMediaBuffer(...)

---

try {
  await handle.sync();
} catch (err) {
  if (process.platform !== "win32" || err?.code !== "EPERM") throw err;
} finally {
  await handle.close();
}
RAW_BUFFERClick to expand / collapse

Summary

On Windows, inbound Telegram media can fail to download/save with EPERM: operation not permitted, fsync. The bot then sends Failed to download media. Please try again. even though Telegram delivered the file.

Environment

  • OpenClaw: 2026.5.3-1
  • OS: Windows 11 / win32
  • Channel: Telegram polling provider
  • Node runtime used by gateway: Node 22.22.2 bundled runtime

Observed behavior

After sending an image to the Telegram bot, OpenClaw logs:

media fetch failed
Error: EPERM: operation not permitted, fsync

The user-facing Telegram reply was:

Failed to download media. Please try again.

Likely cause

In the built package, writeSavedMediaBuffer writes a temp media file, opens it, calls FileHandle.sync(), closes it, then renames. On Windows this sync() call can throw EPERM, even when the file write itself is otherwise fine.

Observed in installed dist file around:

dist/store-D8lbL3Fm.js
writeSavedMediaBuffer(...)

Local workaround tested

Catching Windows-only EPERM around handle.sync() allowed media saving to succeed:

try {
  await handle.sync();
} catch (err) {
  if (process.platform !== "win32" || err?.code !== "EPERM") throw err;
} finally {
  await handle.close();
}

After this local patch, the same media save function successfully wrote inbound images to .openclaw/media/inbound.

Expected behavior

Windows should not fail Telegram media ingestion solely because FileHandle.sync() returns EPERM. OpenClaw should either tolerate this Windows-specific sync failure or use a Windows-safe fsync strategy.

extent analysis

TL;DR

Catch and ignore Windows-specific EPERM errors when calling FileHandle.sync() to allow media saving to succeed.

Guidance

  • Identify the writeSavedMediaBuffer function in the dist/store-D8lbL3Fm.js file and apply the local workaround by wrapping the handle.sync() call in a try-catch block.
  • Verify that the media save function is working correctly by testing the ingestion of inbound images on Windows.
  • Consider using a Windows-safe fsync strategy to avoid relying on error handling for compatibility.
  • Review the Node.js documentation for FileHandle.sync() to understand the implications of ignoring EPERM errors on Windows.

Example

try {
  await handle.sync();
} catch (err) {
  if (process.platform !== "win32" || err?.code !== "EPERM") throw err;
} finally {
  await handle.close();
}

Notes

This workaround may have implications for data integrity on Windows, as EPERM errors are being ignored. Further investigation into the root cause of these errors may be necessary to ensure reliable operation.

Recommendation

Apply the workaround by catching and ignoring Windows-specific EPERM errors, as it allows media saving to succeed and provides a functional solution until a more robust fix can be implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Windows should not fail Telegram media ingestion solely because FileHandle.sync() returns EPERM. OpenClaw should either tolerate this Windows-specific sync failure or use a Windows-safe fsync strategy.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Windows: Telegram media download fails with EPERM on FileHandle.sync() [1 comments, 2 participants]