avajs/ava · error · Error
This version of AVA ( ) does not support any of the desired…
Error message
This version of AVA (${pkg.version}) does not support any of the desired shared worker protocols: ${supportedProtocols.join(',')} What it means
registerSharedWorker negotiates a protocol between the test file and the shared worker. This AVA version only implements the 'ava-4' protocol (lib/worker/plugin.js:98-100); if the caller's supportedProtocols array does not include 'ava-4', AVA throws this Error listing the protocols the caller offered. It means the shared worker (or the plugin wrapper around it) was written for an incompatible AVA protocol generation.
Solutions
- Add 'ava-4' to the supportedProtocols array passed to t.registerSharedWorker().
- Upgrade the shared worker package to a version compatible with your AVA major version, or align AVA's version with the protocol the worker supports.
- Check pkg.version of the installed AVA and the documented protocol list; only 'ava-4' is accepted by this build.
Example fix
// before
t.registerSharedWorker({
filename: new URL('./shared-worker.js', import.meta.url),
supportedProtocols: ['ava-3'],
});
// after
t.registerSharedWorker({
filename: new URL('./shared-worker.js', import.meta.url),
supportedProtocols: ['ava-4'],
}); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_BY_AVA = ['ava-4'];
if (!supportedProtocols.includes('ava-4')) {
throw new Error(`Shared worker requires AVA protocol 'ava-4'; offered: ${supportedProtocols.join(',')}`);
} Prevention
- Always include 'ava-4' in supportedProtocols when using this AVA version.
- Keep shared worker packages in sync with your AVA major version during upgrades.
- Check the AVA changelog when bumping major versions for protocol changes.
When it happens
Trigger: Calling t.registerSharedWorker({ supportedProtocols: [...], ... }) where the array contains anything other than 'ava-4' — e.g. ['ava-3'], ['shared-worker-1'], or a custom protocol name — inside a test file.
Common situations: Using a shared worker package built for a different AVA major version, upgrading/downgrading AVA while keeping an old shared worker, hand-writing supportedProtocols with a guessed protocol name, or a library emitting version-specific protocols like ['ava-5'] that this AVA build does not speak.
Related errors
- Shared worker is not yet available
- Shared workers can be used only when worker threads are…
- Cannot record snapshot
- Could not compare snapshot
- Did not match snapshot
AI-assisted analysis of avajs/ava@bbfd946322 (2026-09-02).
Data as JSON: /api/errors/9d58eb7a34b38918.
Report an issue: GitHub.
Appendix: source
Thrown at lib/worker/plugin.js:99
yield * receiveMessages();
},
};
}
export function registerSharedWorker({
filename,
initialData,
supportedProtocols,
teardown,
}) {
const options_ = getOptions();
if (!options_.workerThreads) {
throw new Error('Shared workers can be used only when worker threads are enabled');
}
if (!supportedProtocols.includes('ava-4')) {
throw new Error(`This version of AVA (${pkg.version}) does not support any of the desired shared worker protocols: ${supportedProtocols.join(',')}`);
}
filename = String(filename); // Allow URL instances.
let worker = workers.get(filename);
if (worker === undefined) {
worker = createSharedWorker(filename, initialData, async () => {
// Run possibly asynchronous teardown functions serially, in reverse
// order. Any error will crash the worker.
const teardownFns = workerTeardownFns.get(worker);
if (teardownFns !== undefined) {
for await (const fn of [...teardownFns].toReversed()) {
await fn();
}
}
});
workers.set(filename, worker);
}View on GitHub (pinned to bbfd946322)