{"record":{"id":"d5baf28573e83922","repo":"BabylonJS/Babylon.js","slug":"feature-not-found","errorCode":null,"errorMessage":"feature not found","messagePattern":"feature not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/XR/webXRFeaturesManager.ts","lineNumber":428,"sourceCode":"            this._AvailableFeatures[featureName].stable = version;\r\n        }\r\n        this._AvailableFeatures[featureName][version] = constructorFunction;\r\n    }\r\n\r\n    /**\r\n     * Returns a constructor of a specific feature.\r\n     *\r\n     * @param featureName the name of the feature to construct\r\n     * @param version the version of the feature to load\r\n     * @param xrSessionManager the xrSessionManager. Used to construct the module\r\n     * @param options optional options provided to the module.\r\n     * @returns a function that, when called, will return a new instance of this feature\r\n     */\r\n    public static ConstructFeature(featureName: string, version: number = 1, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature {\r\n        const constructorFunction = this._AvailableFeatures[featureName][version];\r\n        if (!constructorFunction) {\r\n            // throw an error? return nothing?\r\n            throw new Error(\"feature not found\");\r\n        }\r\n\r\n        return constructorFunction(xrSessionManager, options);\r\n    }\r\n\r\n    /**\r\n     * Can be used to return the list of features currently registered\r\n     *\r\n     * @returns an Array of available features\r\n     */\r\n    public static GetAvailableFeatures() {\r\n        return Object.keys(this._AvailableFeatures);\r\n    }\r\n\r\n    /**\r\n     * Gets the versions available for a specific feature\r\n     * @param featureName the name of the feature\r\n     * @returns an array with the available versions\r","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/XR/webXRFeaturesManager.ts#L410-L446","documentation":"WebXRFeaturesManager.ConstructFeature looks up a constructor in _AvailableFeatures[featureName][version] and returns a factory function. If no constructor is registered for that exact name+version pair, it throws this generic \"feature not found\" Error. It means the requested feature/version combination was never registered (or not imported/registered yet).","triggerScenarios":"Calling WebXRFeaturesManager.ConstructFeature(name, version) (or enableFeature, which calls it) with a featureName absent from the registry, or a version number for which no constructor was registered for that feature.","commonSituations":"Misspelled feature name; requesting version 2 of a feature that only has version 1; tree-shaken builds where the feature module was never imported/registered; calling ConstructFeature directly with a stale version after a library upgrade.","solutions":["Verify the feature name matches a registered WebXR feature constant (e.g. WebXRFeatureName.ANCHOR_SYSTEM) exactly.","Check WebXRFeaturesManager.AvailableFeatures (or the feature's exported versions) for the versions actually registered and pass one of those.","Import the module that registers the feature (side-effect imports in the Babylon XR entrypoint) so it appears in the registry.","Use version \"stable\" or \"latest\" instead of a hardcoded number when unsure.","Wrap in try/catch and fall back to a default feature set if the feature is optional."],"exampleFix":"// before\nWebXRFeaturesManager.ConstructFeature(\"hit-test\", 2, sessionManager);\n// after\nconst version = WebXRFeaturesManager.GetStableVersionOfFeature(WebXRFeatureName.HIT_TEST);\nWebXRFeaturesManager.ConstructFeature(WebXRFeatureName.HIT_TEST, version, sessionManager);","handlingStrategy":"validation","validationCode":"const name = WebXRFeatureName.HIT_TEST;\nconst version = WebXRFeaturesManager.GetStableVersionOfFeature(name);\nif (version === -1) throw new Error(`Feature ${name} not registered`);","typeGuard":"function isFeatureAvailable(name: string, version: number): boolean {\n    return !!WebXRFeaturesManager._AvailableFeatures?.[name]?.[version];\n}","tryCatchPattern":"try {\n    xr.enableFeature(WebXRFeatureName.HIT_TEST, \"stable\");\n} catch (e) {\n    if (String((e as Error).message) === \"feature not found\") {\n    console.warn(\"Feature/version not registered; skipping\");\n    } else { throw e; }\n}","preventionTips":["Use WebXRFeatureName constants instead of hand-typed strings","Prefer \"stable\"/\"latest\" version strings over hardcoded numbers","Ensure the XR feature modules are imported so they self-register","Check GetStableVersionOfFeature/GetLatestVersionOfFeature return -1 as absence signal"],"tags":["webxr","features-manager","configuration","registry"],"backgroundTag":"feature-not-registered","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}