gildas-lormeau/SingleFile · error · Error
Cannot access the tab contents
Error message
Cannot access the tab contents
What it means
captureTab throws this when the tab cannot be captured because its contents are not accessible. Tabs like chrome:// pages, the Web Store, other extensions' pages, or discarded/prerendered tabs do not expose content to content scripts, so no capture can run.
Source
Thrown at src/core/bg/business.js:234
return new Promise((resolve, reject) => {
const taskInfo = addTask({
status: TASK_PENDING_STATE,
tab: {
id: tab.id,
index: tab.index,
url: tab.url,
title: tab.title
},
options: tabOptions,
method: "content.capture",
resolve,
reject
});
taskInfo.cancel = () => reject(new Error("SingleFile capture was cancelled"));
runTasks();
});
}
throw new Error("Cannot access the tab contents");
}
function addTask(info) {
const taskInfo = {
id: currentTaskId,
status: info.status,
tab: info.tab,
options: info.options,
method: info.method,
resolve: info.resolve,
reject: info.reject,
done: function (runNextTasks = true) {
const index = tasks.findIndex(taskInfo => taskInfo.id == this.id);
if (index > -1) {
tasks.splice(index, 1);
if (runNextTasks) {
runTasks();
}View on GitHub (pinned to 517fb7c5cf)
Solutions
- Filter out non-capturable URLs (chrome://, about:, Web Store) before calling captureTab
- Ensure host permissions/content script access is granted for the target URL
- Activate the tab and check tab.status === 'complete' and a real http(s)/file URL before capture
- Catch the error and skip or report the tab as non-capturable
Example fix
// before
const results = await Promise.all(tabs.map(t => singlefile.captureTab(t)));
// after
const capturable = tabs.filter(t => /^https?:/.test(t.url || ''));
const results = [];
for (const t of capturable) {
try { results.push(await singlefile.captureTab(t)); }
catch (e) { if (e.message === 'Cannot access the tab contents') continue; throw e; }
} Defensive patterns
Strategy: validation
Validate before calling
const capturable = tab && tab.id != null && /^https?:/i.test(tab.url || '') && tab.status === 'complete'; if (!capturable) throw new SkipCapture();
Type guard
const canCapture = (tab) => Boolean(tab && typeof tab.id === 'number' && /^https?:/i.test(tab.url || ''));
Try / catch
try { return await captureTab(tab); } catch (e) { if (e.message === 'Cannot access the tab contents') return skip(tab); throw e; } Prevention
- Filter chrome://, about:, and store URLs before capture
- Declare host permissions for all URLs you intend to capture
- Ensure the tab is active/complete before capturing
- Avoid capturing tabs from other profiles or incognito without permission
When it happens
Trigger: captureTab called on a privileged/protected page (chrome://, edge://, extension pages, Web Store) or a tab without an injectable content script (no host permissions, discarded tab, missing tabId).
Common situations: Batch-capturing all open tabs and hitting restricted browser pages; capturing tabs from other windows/profiles; missing 'tabs' or host permissions in manifest; capturing a discarded tab.
Related errors
- Cannot identify the extension requesting SingleFile capture
- Unauthorized sender
- SingleFile capture was not approved for this extension
AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01).
Data as JSON: /api/errors/302b18770eec286e.
Report an issue: GitHub.