videojs/video.js · warning · Error
Techs must have a static canPlaySource method on them
Error message
Techs must have a static canPlaySource method on them
What it means
Intended to ensure a registered tech exposes a static canPlaySource method. NOTE: the guard checks 'Tech.canPlaySource' (the base Tech class) rather than 'tech.canPlaySource' (the argument). The base class defines static canPlaySource at src/js/tech/tech.js:981, so this check effectively always passes and is unreachable in normal use. To hit it you must delete or overwrite Tech.canPlaySource before calling registerTech.
Source
Thrown at src/js/tech/tech.js:1025
* Name of the `Tech` to register.
*
* @param {Object} tech
* The `Tech` class to register.
*/
static registerTech(name, tech) {
if (!Tech.techs_) {
Tech.techs_ = {};
}
if (!Tech.isTech(tech)) {
throw new Error(`Tech ${name} must be a Tech`);
}
if (!Tech.canPlayType) {
throw new Error('Techs must have a static canPlayType method on them');
}
if (!Tech.canPlaySource) {
throw new Error('Techs must have a static canPlaySource method on them');
}
name = toTitleCase(name);
Tech.techs_[name] = tech;
Tech.techs_[toLowerCase(name)] = tech;
if (name !== 'Tech') {
// camel case the techName for use in techOrder
Tech.defaultTechOrder_.push(name);
}
return tech;
}
/**
* Get a `Tech` from the shared list by name.
*
* @param {string} name
* `camelCase` or `TitleCase` name of the Tech to getView on GitHub (pinned to c3a7e0e6d2)
Solutions
- Do not delete or override Tech.canPlayType / Tech.canPlaySource on the base class.
- If you actually need to validate a tech exposes canPlaySource, check the tech argument directly: if (!tech.canPlaySource).
- Report the upstream check-vs-argument bug (Tech.canPlaySource should be tech.canPlaySource).
Defensive patterns
Strategy: type-guard
Validate before calling
function registerTechSafe(name, tech) {
if (typeof tech.canPlaySource !== 'function') {
throw new TypeError(`${name} must define a static canPlaySource method`);
}
videojs.registerTech(name, tech);
} Type guard
function techHasCanPlaySource(tech) {
return typeof tech.canPlaySource === 'function';
} Prevention
- Do not delete or monkeypatch Tech.canPlaySource on the base class.
- Validate the tech argument directly (tech.canPlaySource) since the built-in guard checks the base class instead.
- In tests, mock the tech argument, not the base Tech class statics.
When it happens
Trigger: Only fires if Tech.canPlaySource on the base class has been deleted, monkeypatched to a falsy value, or never assigned (aggressive test mock, or a fork that removed the base static method). Real custom techs inherit the method and never trigger it.
Common situations: Essentially unreachable in production. May surface in unit tests that stub the Tech class, or in a downstream fork that strips base-class statics.
Related errors
- Techs must have a static canPlayType method on them
- Tech ${name} must be a Tech
- Illegal component, "${name}"; ${reason}.
- No techOrder specified. Did you overwrite videojs.options in
- No Tech named '${titleTechName}' exists! '${titleTechName}'
AI-assisted analysis of videojs/video.js@c3a7e0e6d2 (2026-08-13).
Data as JSON: /api/errors/711a553cf97f9fbe.
Report an issue: GitHub.