microsoft/playwright · error · Error
Connecting to workers is only supported in Chromium.
Error message
Connecting to workers is only supported in Chromium.
What it means
Thrown by BrowserType._connectToWorker() when the BrowserType name is not chromium. Worker (service worker / web worker) target attachment via CDP is a Chromium-only feature, so firefox/webkit are rejected up front.
Source
Thrown at packages/playwright-core/src/client/browserType.ts:186
slowMo: params.slowMo,
isLocal: params.isLocal,
noDefaults: params.noDefaults,
artifactsDir: params.artifactsDir,
}, new TimeoutSettings().timeout(params));
return await this._browserFromConnectResult(result);
}
private async _browserFromConnectResult(result: { browser: channels.BrowserChannel, defaultContext?: channels.BrowserContextChannel }): Promise<Browser> {
const browser = Browser.from(result.browser);
browser._connectToBrowserType(this, {}, undefined);
if (result.defaultContext)
await this._instrumentation.runAfterCreateBrowserContext(BrowserContext.from(result.defaultContext));
return browser;
}
async _connectToWorker(endpoint: string, options: { timeout?: number } = {}): Promise<Worker> {
if (this.name() !== 'chromium')
throw new Error('Connecting to workers is only supported in Chromium.');
const result = await this._channel.connectToWorker({
endpoint,
}, new TimeoutSettings().timeout(options));
return Worker.from(result.worker);
}
}
function isConnectionTransport(value: any): value is api.ConnectOverCDPTransport {
return !!value && typeof value === 'object' && typeof value.send === 'function' && typeof value.close === 'function';
}
View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Restrict worker attachment to chromium.
- For non-chromium engines, attach at page level only (no worker targets).
- Branch on browserType.name() === 'chromium' before calling _connectToWorker.
Example fix
// before await browserType._connectToWorker(endpoint); // after if (browserType.name() === 'chromium') await browserType._connectToWorker(endpoint);
Defensive patterns
Strategy: type-guard
Validate before calling
if (browserType.name() !== 'chromium')
throw new Error('Worker attachment is chromium-only.'); Type guard
function supportsWorkerConnect(bt: any): boolean {
return bt?.name?.() === 'chromium';
} Prevention
- Branch worker-target tooling on browser name.
- Treat _connectToWorker as chromium-only even though the method exists on all BrowserTypes.
When it happens
Trigger: Calling the internal `_connectToWorker(endpoint)` on firefox or webkit. This is an internal method exercised by tooling/CDP integrations that attach to worker targets.
Common situations: Custom tooling that abstracts over all BrowserTypes and tries worker attachment uniformly; experimental integrations ported from chromium to other engines.
Related errors
- Connecting over CDP is only supported in Chromium and WebKit
- Root session cannot be closed
- Cannot disconnect from this worker
- page: expected Page or Frame
- Passing a ConnectionTransport to connectOverCDP is not suppo
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/ddf71ea6732790aa.
Report an issue: GitHub.