{"record":{"id":"ff741c6860ea21b3","repo":"gildas-lormeau/SingleFile","slug":"upload-cancelled","errorCode":"upload_cancelled","errorMessage":"upload_cancelled","messagePattern":"upload_cancelled","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/core/bg/downloads.js","lineNumber":265,"sourceCode":"\t\t\t\t\tmessage.url = URL.createObjectURL(new Blob(contents, { type: message.mimeType }));\n\t\t\t\t}\n\t\t\t\tresponse = await downloadPage(message, {\n\t\t\t\t\tconfirmFilename: message.confirmFilename,\n\t\t\t\t\tincognito,\n\t\t\t\t\tfilenameConflictAction: message.filenameConflictAction,\n\t\t\t\t\tfilenameReplacementCharacter: message.filenameReplacementCharacter,\n\t\t\t\t\tbookmarkId: message.bookmarkId,\n\t\t\t\t\treplaceBookmarkURL: message.replaceBookmarkURL,\n\t\t\t\t\tincludeInfobar: message.includeInfobar,\n\t\t\t\t\topenInfobar: message.openInfobar,\n\t\t\t\t\tinfobarPositionAbsolute: message.infobarPositionAbsolute,\n\t\t\t\t\tinfobarPositionTop: message.infobarPositionTop,\n\t\t\t\t\tinfobarPositionBottom: message.infobarPositionBottom,\n\t\t\t\t\tinfobarPositionLeft: message.infobarPositionLeft,\n\t\t\t\t\tinfobarPositionRight: message.infobarPositionRight\n\t\t\t\t});\n\t\t\t\tif (!response) {\n\t\t\t\t\tthrow new Error(\"upload_cancelled\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (message.bookmarkId && message.replaceBookmarkURL && response && response.url) {\n\t\t\t\tawait bookmarks.update(message.bookmarkId, { url: response.url });\n\t\t\t}\n\t\t\tui.onEnd(tabId);\n\t\t\tif (message.openSavedPage && !message.openEditor) {\n\t\t\t\tconst createTabProperties = { active: true, url: \"/src/ui/pages/viewer.html?blobURI=\" + URL.createObjectURL(new Blob(contents, { type: message.mimeType })), windowId: tab.windowId };\n\t\t\t\tif (tab.index != null) {\n\t\t\t\t\tcreateTabProperties.index = tab.index + 1;\n\t\t\t\t}\n\t\t\t\tbrowser.tabs.create(createTabProperties);\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tif (!error.message || error.message != \"upload_cancelled\") {\n\t\t\tconsole.error(error); // eslint-disable-line no-console\n\t\t\tui.onError(tabId, error.message, error.link);","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/gildas-lormeau/SingleFile/blob/517fb7c5cf2096d89933b747e862d8ecf616a9f9/src/core/bg/downloads.js#L247-L283","documentation":"In downloadContent, after asking the page's content script (via messaging) to collect/prepare the page data for upload/processing, a null/absent response throws Error('upload_cancelled'). It means the foreground upload step did not return a result — typically the user closed the infobar/cancelled, or the content script did not answer.","triggerScenarios":"User cancels the upload/processing infobar shown in the tab; the content script fails to respond (page navigated, tab closed, content script not injected) so messaging resolves with no response.","commonSituations":"Saving a page where the user dismisses the progress/confirm infobar; pages where the content script was reloaded mid-save; saving from a discarded tab.","solutions":["Treat it as an intentional cancellation: catch and exit silently without retrying.","Retry the download if cancellation was unintended (re-invoke downloadTabPage to re-show the infobar).","Ensure the content script is injected/alive before starting (check tab status is 'complete')."],"exampleFix":"// before\nawait downloadTabPage(tabId, message);\n// after\ntry { await downloadTabPage(tabId, message); }\ncatch (err) { if (err.message !== 'upload_cancelled') throw err; }\n","handlingStrategy":"try-catch","validationCode":"const tab = await browser.tabs.get(tabId);\nif (tab.status !== 'complete') await waitForTabComplete(tabId); // content script must be alive","typeGuard":null,"tryCatchPattern":"try { await downloadTabPage(tabId, message); } catch (e) { if (e.message === 'upload_cancelled') return; throw e; }","preventionTips":["Treat cancellation as a normal outcome, not a failure","Ensure the tab is active and loaded before saving","Avoid retry loops on this error — it is user-initiated"],"tags":["cancellation","messaging","download"],"backgroundTag":"upload-cancelled","analyzedSha":"517fb7c5cf2096d89933b747e862d8ecf616a9f9","analyzedAt":"2026-09-01T10:05:25.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}