libnyanpasu/clash-nyanpasu · warning
flushing the system DNS cache is not supported on this platf
Error message
flushing the system DNS cache is not supported on this platform
What it means
flush_system_dns_cache is a platform-gated helper that shells out to OS tools to clear the OS DNS resolver cache. On unsupported platforms (anything that is neither Windows nor macOS) the #[cfg] fallback deliberately aborts with this bail instead of attempting a command, because there is no portable way to flush DNS. Callers must treat DNS-cache flushing as a best-effort, platform-dependent capability.
Source
Thrown at backend/tauri/src/client/system_dns.rs:53
.status()
.context("failed to request permission to flush the Windows DNS cache")?;
ensure_success(status, "ipconfig /flushdns")
}
#[cfg(target_os = "macos")]
fn flush_system_dns_cache() -> anyhow::Result<()> {
let status = std::process::Command::new("/usr/bin/osascript")
.args(["-e", MACOS_SCRIPT])
.status()
.context("failed to request permission to flush the macOS DNS cache")?;
ensure_success(status, "macOS DNS cache flush")
}
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
fn flush_system_dns_cache() -> anyhow::Result<()> {
anyhow::bail!("flushing the system DNS cache is not supported on this platform")
}
#[cfg(any(target_os = "windows", target_os = "macos"))]
fn ensure_success(status: std::process::ExitStatus, operation: &str) -> anyhow::Result<()> {
if status.success() {
Ok(())
} else {
anyhow::bail!("{operation} failed with status {status}")
}
}
#[cfg(test)]
#[derive(Debug, Default)]
pub struct NoopSystemDnsCache;
#[cfg(test)]
impl SystemDnsCache for NoopSystemDnsCache {
fn flush(&self) -> anyhow::Result<()> {View on GitHub (pinned to f7dbce2997)
Solutions
- Guard the call behind a cfg(all(windows, target_os = "macos")) check or an is_supported() predicate and skip flushing on other platforms
- Log the failure as a warning and continue the calling flow (DNS flush is best-effort, not required for proxy correctness)
- Optionally extend support by implementing Linux flush (e.g. resolvectl flush-caches) behind a new cfg arm
Example fix
// before
flush_system_dns_cache()?;
// after
#[cfg(any(target_os = "windows", target_os = "macos"))]
if let Err(e) = flush_system_dns_cache() {
log::warn!("DNS cache flush skipped: {e}");
} Defensive patterns
Strategy: fallback
Validate before calling
fn can_flush_dns() -> bool {
cfg!(any(target_os = "windows", target_os = "macos"))
} Type guard
fn dns_flush_supported() -> bool {
cfg!(any(target_os = "windows", target_os = "macos"))
} Try / catch
match flush_system_dns_cache() {
Err(e) if e.to_string().contains("not supported") => log::info!("DNS flush unsupported; skipping"),
other => other?,
} Prevention
- Check platform capability before calling
- Treat DNS flush as best-effort, never propagate as fatal
- Log skipped flushes for diagnostics
When it happens
Trigger: Calling flush_system_dns_cache() on a Linux/BSD or any non-Windows/non-macOS target; the cfg-gated stub compiles to an unconditional bail, so every call on such a platform fails immediately.
Common situations: Running nyanpasu on Linux and toggling system proxy/TUN in a flow that also tries to flush DNS; CI builds targeting unsupported platforms; distro-specific expectations that DNS can be flushed via systemd-resolved (not implemented here).
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- unimplemented!()
- IPC server is already initialized
- application actor call timed out
- clash config actor reply dropped
- clash config actor call timed out
AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08).
Data as JSON: /api/errors/128032ec02c988dd.
Report an issue: GitHub.