{"record":{"id":"e6ad71e8aa7b406a","repo":"phaserjs/phaser","slug":"unknown-value-for-renderer-type","errorCode":null,"errorMessage":"Unknown value for renderer type: ","messagePattern":"Unknown value for renderer type: ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/CreateRenderer.js","lineNumber":57,"sourceCode":"    //  Not a custom environment, didn't provide their own canvas and not headless, so determine the renderer:\n    if (!config.customEnvironment && !config.canvas && config.renderType !== CONST.HEADLESS)\n    {\n        if (config.renderType === CONST.AUTO)\n        {\n            config.renderType = Features.webGL ? CONST.WEBGL : CONST.CANVAS;\n        }\n\n        if (config.renderType === CONST.WEBGL)\n        {\n            if (!Features.webGL) { throw new Error('Cannot create WebGL context, aborting.'); }\n        }\n        else if (config.renderType === CONST.CANVAS)\n        {\n            if (!Features.canvas) { throw new Error('Cannot create Canvas context, aborting.'); }\n        }\n        else\n        {\n            throw new Error('Unknown value for renderer type: ' + config.renderType);\n        }\n    }\n\n    //  Pixel Art mode?\n    if (!config.antialias)\n    {\n        CanvasPool.disableSmoothing();\n    }\n\n    var baseSize = game.scale.baseSize;\n\n    var width = baseSize.width;\n    var height = baseSize.height;\n\n    //  Does the game config provide its own canvas element to use?\n    if (config.canvas)\n    {\n        game.canvas = config.canvas;","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/core/CreateRenderer.js#L39-L75","documentation":"After the AUTO branch resolves and the WEBGL/CANVAS branches are checked, any other `renderType` value falls into the `else` at CreateRenderer.js:57 and throws with the offending value appended. This catches numeric values that are not one of the CONST renderer enums.","triggerScenarios":"Thrown at src/core/CreateRenderer.js:57 when the library encounters an invalid state.","commonSituations":"Using a constant that was renamed/removed across Phaser versions; passing `type: 'webgl'` (string) instead of `Phaser.WEBGL`; copy-pasting a config whose `type` field came from an unrelated library.","solutions":["Use the official enum constants: `Phaser.AUTO`, `Phaser.CANVAS`, `Phaser.WEBGL`, or `Phaser.HEADLESS`.","Inspect the appended value in the message — it reveals the bad input immediately.","Upgrade/audit the config against the current Phaser version's CONST module."],"exampleFix":"// before\ntype: 'webgl' // string, not an enum\n// after\ntype: Phaser.WEBGL","handlingStrategy":"validation","validationCode":"const VALID = [Phaser.AUTO, Phaser.CANVAS, Phaser.WEBGL, Phaser.HEADLESS]\nif (!VALID.includes(cfg.type)) {\n  throw new Error(`Invalid renderType: ${cfg.type}. Use a Phaser.* constant.`)\n}","typeGuard":"const isRenderType = (v) =>\n  v === Phaser.AUTO || v === Phaser.CANVAS || v === Phaser.WEBGL || v === Phaser.HEADLESS","tryCatchPattern":null,"preventionTips":["Always use the Phaser.* enum constants, never raw numbers or strings.","Add a config schema check (zod/joi) at app startup if configs are dynamic.","Pin the Phaser version and re-audit config constants on upgrade."],"tags":["config","renderer","enum","startup"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}