gildas-lormeau/SingleFile · warning · Error
upload_cancelled
upload_cancelled
Error message
upload_cancelled
What it means
sendFile throws "upload_cancelled" during a resumable (chunked) upload when the Drive API responds with HTTP 308 (Resume Incomplete) and the mediaUploader has been marked cancelled. Instead of recursing to send the next chunk, the upload is aborted with this error so callers can distinguish an intentional cancellation from a network failure.
Source
Thrown at src/lib/gdrive/gdrive.js:464
"Authorization": "Bearer " + mediaUploader.token,
"Content-Type": mediaUploader.contentType,
"Content-Range": "bytes " + mediaUploader.offset + "-" + (end - 1) + "/" + mediaUploader.file.size,
"X-Upload-Content-Type": mediaUploader.contentType
},
body: content
});
if (mediaUploader.onProgress && !mediaUploader.cancelled) {
mediaUploader.onProgress(mediaUploader.offset + mediaUploader.chunkSize, mediaUploader.file.size);
}
if (httpResponse.status == 200 || httpResponse.status == 201) {
return httpResponse.json();
} else if (httpResponse.status == 308) {
const range = httpResponse.headers.get("Range");
if (range) {
mediaUploader.offset = parseInt(range.match(/\d+/g).pop(), 10) + 1;
}
if (mediaUploader.cancelled) {
throw new Error("upload_cancelled");
} else {
return sendFile(mediaUploader);
}
} else {
getResponse(httpResponse);
}
}
async function getJSON(httpResponse) {
httpResponse = getResponse(httpResponse);
const response = await httpResponse.json();
if (response.error) {
throw new Error(response.error);
} else {
return response;
}
}
View on GitHub (pinned to 517fb7c5cf)
Solutions
- If cancellation was unintentional, do not set cancelled before the upload finishes; restart the upload from scratch.
- Resume instead of cancelling: create a new uploader positioned at mediaUploader.offset (derived from the 308 Range header) and call sendFile again.
- Handle the error in UI code by showing the upload as cancelled and offering a retry.
- Check that no shared uploader instance is being cancelled by another concurrent request.
Example fix
// before uploader.cancel(); // later: Error: upload_cancelled // after // don't cancel; resume from server-reported offset const offset = uploader.offset; uploader.startAt(offset); await sendFile(uploader);
Defensive patterns
Strategy: try-catch
Validate before calling
// before starting: ensure no cancel is pending
if (uploader.cancelled) throw new Error("start aborted: uploader already cancelled"); Try / catch
try { await upload(mediaUploader); }
catch (e) {
if (e.message === "upload_cancelled") { markUploadCancelledInUI(mediaUploader.name); return; }
throw e;
} Prevention
- Only cancel uploads from explicit user actions
- Resume from the offset in the 308 Range header instead of restarting from zero
- Disable the Cancel button once the final chunk has been sent
When it happens
Trigger: Calling the cancel() method on the uploader (or setting mediaUploader.cancelled = true) while a multi-chunk upload is in progress; the next 308 response from the resumable endpoint then observes cancelled === true and throws.
Common situations: User presses a Cancel button during a large file upload; app cancels uploads on navigation; timeouts that cancel in-flight uploads; testing partial-upload recovery logic.
Related errors
- error.message + " (GitHub)"
- error.message + " (S3)"
- error.message + " (WebDAV)"
- error.message + " (MCP)"
- error.message + " (RestFormApi)"
AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01).
Data as JSON: /api/errors/693268a281e4dc19.
Report an issue: GitHub.