BabylonJS/Babylon.js · error · Error
Connect failed
Error message
Connect failed
What it means
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.
Source
Thrown at packages/dev/core/src/AudioV2/abstractAudio/audioBus.ts:73
if (this._outBus === outBus) {
return;
}
if (this._outBus) {
this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);
if (!this._disconnect(this._outBus)) {
throw new Error("Disconnect failed");
}
}
this._outBus = outBus;
if (this._outBus) {
this._outBus.onDisposeObservable.add(this._onOutBusDisposed);
if (!this._connect(this._outBus)) {
throw new Error("Connect failed");
}
}
}
/**
* The spatial audio features.
*/
public get spatial(): AbstractSpatialAudio {
if (this._spatial) {
return this._spatial;
}
return this._initSpatialProperty();
}
/**
* The stereo features of the audio bus.
*/
public abstract readonly stereo: AbstractStereoAudio;View on GitHub (pinned to 0592b347b8)
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.
Example fix
// before
const sfx = new AudioBus("SFX");
sfx.outBus = mainBus; // engine not ready -> Connect failed
// after
await engine.initAsync();
const sfx = new AudioBus("SFX");
sfx.outBus = mainBus; Defensive patterns
Strategy: validation
Validate before calling
function canWireBusToBus(engine, target) {
return engine.state === 'started' && !!target && !target.isDisposed && engine.buses.includes(target);
}
if (canWireBusToBus(audioEngine, mainBus)) sfxBus.outBus = mainBus; Type guard
function isEngineOwnedBus(x, engine) {
return x instanceof AudioBus && engine.buses.includes(x) && !x.isDisposed;
} Try / catch
try {
sfxBus.outBus = mainBus;
} catch (e) {
if (e.message === 'Connect failed') {
await audioEngine.initAsync();
sfxBus.outBus = mainBus;
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Connect failed
- Disconnect failed
- The value passed to [Scene.audioListenerPositionProvider] mu
- The value passed to [Scene.audioListenerRotationProvider] mu
- Disconnect failed
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/464c3bf19e24ea25.
Report an issue: GitHub.