{"record":{"id":"464c3bf19e24ea25","repo":"BabylonJS/Babylon.js","slug":"connect-failed-464c3b","errorCode":null,"errorMessage":"Connect failed","messagePattern":"Connect failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/AudioV2/abstractAudio/audioBus.ts","lineNumber":73,"sourceCode":"        if (this._outBus === outBus) {\n            return;\n        }\n\n        if (this._outBus) {\n            this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n\n            if (!this._disconnect(this._outBus)) {\n                throw new Error(\"Disconnect failed\");\n            }\n        }\n\n        this._outBus = outBus;\n\n        if (this._outBus) {\n            this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n\n            if (!this._connect(this._outBus)) {\n                throw new Error(\"Connect failed\");\n            }\n        }\n    }\n\n    /**\n     * The spatial audio features.\n     */\n    public get spatial(): AbstractSpatialAudio {\n        if (this._spatial) {\n            return this._spatial;\n        }\n        return this._initSpatialProperty();\n    }\n\n    /**\n     * The stereo features of the audio bus.\n     */\n    public abstract readonly stereo: AbstractStereoAudio;","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/AudioV2/abstractAudio/audioBus.ts#L55-L91","documentation":"AudioBus.outBus setter throws \"Connect failed\" when, after detaching any previous bus, it subscribes to the new bus's dispose observable and _connect(this._outBus) returns false. Same family as error 35 but on the AudioBus class: chaining buses fails because the audio engine cannot connect the bus's node to the target bus's node.","triggerScenarios":"Assigning audioBus.outBus to a disposed bus, to a bus not yet added/created on a started engine, or calling the setter before the AudioEngine V2 is initialized/started.","commonSituations":"Building nested bus graphs (SFX -> music bus -> main output) at startup before awaiting engine readiness; passing a bus from a different engine instance; typo leading to an undefined/disposed bus reference.","solutions":["Await AudioEngineV2 init/start before wiring bus-to-bus connections.","Verify the target bus belongs to the same engine instance and is not disposed.","Create buses via the engine API after engine readiness and keep live references.","Retry the assignment in try/catch once the engine reports ready."],"exampleFix":"// before\nconst sfx = new AudioBus(\"SFX\");\nsfx.outBus = mainBus; // engine not ready -> Connect failed\n\n// after\nawait engine.initAsync();\nconst sfx = new AudioBus(\"SFX\");\nsfx.outBus = mainBus;","handlingStrategy":"validation","validationCode":"function canWireBusToBus(engine, target) {\n  return engine.state === 'started' && !!target && !target.isDisposed && engine.buses.includes(target);\n}\nif (canWireBusToBus(audioEngine, mainBus)) sfxBus.outBus = mainBus;","typeGuard":"function isEngineOwnedBus(x, engine) {\n  return x instanceof AudioBus && engine.buses.includes(x) && !x.isDisposed;\n}","tryCatchPattern":"try {\n  sfxBus.outBus = mainBus;\n} catch (e) {\n  if (e.message === 'Connect failed') {\n    await audioEngine.initAsync();\n    sfxBus.outBus = mainBus;\n  } else throw e;\n}","preventionTips":["Build the bus graph after engine readiness, not in module top-level code.","Validate same-engine ownership before connecting buses.","Subscribe to target bus onDisposeObservable to null stale links.","Prefer engine-provided default buses (mainBus) over hand-constructed ones unless needed."],"tags":["audio","webaudio","babylonjs","initialization-order"],"backgroundTag":"audio-node-connect-failed","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}