arduino/Arduino · error · Exception
Incomplete download
Error message
Incomplete download
What it means
FileDownloader throws this generic Exception when the stream ends but fewer bytes than the declared download size (getDownloadSize()) were received. It guards against silently saving a truncated file as a complete download.
Source
Thrown at arduino-core/src/cc/arduino/utils/network/FileDownloader.java:266
byte[] buffer = new byte[10240];
while (status == Status.DOWNLOADING) {
int read = stream.read(buffer);
if (read == -1)
break;
randomAccessOutputFile.write(buffer, 0, read);
setDownloaded(getDownloaded() + read);
if (Thread.interrupted()) {
randomAccessOutputFile.close();
throw new InterruptedException();
}
}
if (getDownloadSize() != null) {
if (getDownloaded() < getDownloadSize())
throw new Exception("Incomplete download");
}
} finally {
IOUtils.closeQuietly(stream);
}
}
private void setError(Exception e) {
error = e;
}
public Exception getError() {
return error;
}
public boolean isCompleted() {
return status == Status.COMPLETE;
}
}View on GitHub (pinned to a0df6e0e83)
Solutions
- Retry the download (the downloader supports resume: it reopens the connection and appends from the already-downloaded offset)
- Check network stability (disable VPN/proxy, use wired connection) and retry
- Verify the server actually serves the full content-length (curl and compare size)
- Download the file manually and install it offline if the server keeps truncating
Example fix
// before: single attempt
downloader.downloadFile(url, file, false);
// after: retry with resume
for (int i = 0; i < 3; i++) {
try { downloader.downloadFile(url, file, false); break; }
catch (Exception e) { if (i == 2) throw e; sleep(retryTimeout); }
} Defensive patterns
Strategy: retry
Try / catch
try {
downloader.downloadFile(url, file, false);
} catch (Exception e) {
if ("Incomplete download".equals(e.getMessage())) {
// FileDownloader resumes from downloaded bytes
downloader.downloadFile(url, file, false); // retry resumes
} else throw e;
} Prevention
- Run downloads on stable networks; avoid suspending the machine mid-download
- Avoid proxies/VPNs known to cut long-lived connections
- Check the downloaded file size against the server content-length afterward
- Always retry rather than trusting a file from a failed download session
When it happens
Trigger: readStreamCopyTo() finishes reading the connection stream (read() returned -1) while getDownloaded() < getDownloadSize(); i.e. the server closed the connection early or the content-length does not match the bytes delivered.
Common situations: Unstable or metered network dropping the connection mid-download; server-side truncation of large archives; proxy/CDN closing idle connections; VPN or Wi-Fi interruptions.
Related errors
- CRC doesn't match, file is corrupted. It may be a temporary
- Error downloading {0}
- Received invalid http status code from server: {resp}
- Can't download {0}: invalid filename or exinsting directory
- Unable to understand proxy settings
AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06).
Data as JSON: /api/errors/2250b42922b71341.
Report an issue: GitHub.