{"record":{"id":"442678a234173fef","repo":"phaserjs/phaser","slug":"no-cached-audio-asset-with-key","errorCode":null,"errorMessage":"No cached audio asset with key \"","messagePattern":"No cached audio asset with key \"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/sound/html5/HTML5AudioSound.js","lineNumber":63,"sourceCode":"\n    function HTML5AudioSound (manager, key, config)\n    {\n        if (config === undefined) { config = {}; }\n\n        /**\n         * An array containing all HTML5 Audio tags that could be used for individual\n         * sound playback. Number of instances depends on the config value passed\n         * to the `Loader#audio` method call, default is 1.\n         *\n         * @name Phaser.Sound.HTML5AudioSound#tags\n         * @type {HTMLAudioElement[]}\n         * @since 3.0.0\n         */\n        this.tags = manager.game.cache.audio.get(key);\n\n        if (!this.tags)\n        {\n            throw new Error('No cached audio asset with key \"' + key);\n        }\n\n        /**\n         * Reference to an HTML5 Audio tag used for playing sound.\n         *\n         * @name Phaser.Sound.HTML5AudioSound#audio\n         * @type {HTMLAudioElement}\n         * @default null\n         * @since 3.0.0\n         */\n        this.audio = null;\n\n        /**\n         * Timestamp as generated by the Request Animation Frame or SetTimeout\n         * representing the time at which the delayed sound playback should start.\n         * Set to 0 if sound playback is not delayed.\n         *\n         * @name Phaser.Sound.HTML5AudioSound#startTime","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/sound/html5/HTML5AudioSound.js#L45-L81","documentation":"Thrown by HTML5AudioSound constructor when manager.game.cache.audio.get(key) returns a falsy value, meaning no audio asset was loaded under that key. The HTML5 Audio sound backend requires the asset to be in the audio cache before a Sound instance is created from it. Note the error message text has an unclosed quote (a known cosmetic bug) but the cause is purely a cache miss.","triggerScenarios":"Constructing new Phaser.Sound.HTML5AudioSound(manager, key) for a key never loaded; misspelling the key vs. the loader key; loading under a different cache bucket; calling sound.add before the loader has finished.","commonSituations":"Forgetting this.load.audio('key', url) before sound.add('key'); using the wrong key casing; the load failed (404 / decode error) so the cache entry is absent; audio disabled in config so nothing was cached; calling from preload() instead of create().","solutions":["Preload the audio with this.load.audio(key, url) and use the same key.","Move sound.add calls into create() or a loader complete callback so the cache is populated.","Verify with this.game.cache.audio.has(key) before constructing the sound.","Check the Network panel for failed audio requests during preload."],"exampleFix":"// before\n// in preload: (forgot to load)\nconst s = this.sound.add('beep'); // throws\n\n// after\npreload() { this.load.audio('beep', 'audio/beep.mp3'); }\ncreate() { const s = this.sound.add('beep'); }","handlingStrategy":"validation","validationCode":"function addHtml5Sound(manager, key) {\n  if (!manager.game.cache.audio.has(key)) {\n    throw new Error(`Audio '${key}' not in cache; call this.load.audio first`);\n  }\n  return new Phaser.Sound.HTML5AudioSound(manager, key);\n}","typeGuard":"function audioCached(game, key) { return game.cache.audio.has(key); }","tryCatchPattern":null,"preventionTips":["Preload audio with this.load.audio using the exact key.","Defer sound.add to create() or loader complete.","Check cache.has before constructing."],"tags":["audio","sound","cache","html5-audio","loader"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}