phaserjs/phaser · error · Error
node constructor
Error message
node constructor
What it means
Thrown by RenderNodeManager.addNodeConstructor when a constructor function is registered for a name that already has one in this._nodeConstructors. The constructor registry powers lazy node instantiation via getNode, so a duplicate would create ambiguity about which class to build.
Source
Thrown at src/renderer/webgl/renderNodes/RenderNodeManager.js:336
node.setDebug(true);
}
},
/**
* Add a constructor for a node to the manager.
* This will allow the node to be constructed when `getNode` is called.
*
* @method Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager#addNodeConstructor
* @since 4.0.0
* @param {string} name - The name of the node.
* @param {function} constructor - The constructor for the node.
* @throws {Error} Will throw an error if the node constructor already exists.
*/
addNodeConstructor: function (name, constructor)
{
if (this._nodeConstructors[name])
{
throw new Error('node constructor ' + name + ' already exists.');
}
this._nodeConstructors[name] = constructor;
},
/**
* Get a node from the manager.
*
* If the node does not exist, and a constructor is available,
* it will be constructed and added to the manager,
* then returned.
*
* @method Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager#getNode
* @since 4.0.0
* @param {string} name - The name of the node.
* @return {?Phaser.Renderer.WebGL.RenderNodes.RenderNode} The node, or null if it does not exist.
*/
getNode: function (name)
{View on GitHub (pinned to 41be1e462b)
Solutions
- Guard registration: if (!manager._nodeConstructors[name]) manager.addNodeConstructor(name, ctor);
- Namespace constructor names by plugin/feature.
- Move registration to a one-time bootstrap, not per-scene init.
- On plugin destroy, only removeNode; do not re-register on re-create.
Example fix
// before
manager.addNodeConstructor('MyNode', MyCtor); // throws on second load
// after
if (!manager._nodeConstructors['MyNode']) {
manager.addNodeConstructor('MyNode', MyCtor);
} Defensive patterns
Strategy: validation
Validate before calling
if (!manager._nodeConstructors[name]) { manager.addNodeConstructor(name, ctor); } Type guard
function isCtorRegistered(manager, name) { return Boolean(manager._nodeConstructors && manager._nodeConstructors[name]); } Prevention
- Guard registration calls with a presence check.
- Move registration to a one-time init.
- Use namespaced names to avoid collisions.
When it happens
Trigger: Calling manager.addNodeConstructor(name, ctor) twice with the same name; a plugin registering a constructor whose name collides with a built-in or another plugin's constructor; calling a registration helper on every scene start.
Common situations: Plugins that register render nodes on init without checking if already registered; hot module reload re-running the registration code; two libraries both extending the same node slot.
Related errors
- node
- BatchHandler must have a name
- BatchHandlerStrip: Vertex count exceeds maximum per batch (
- BaseFilterShader: No fragment shader source provided and no
- Color attachments must have the same dimensions
AI-assisted analysis of phaserjs/phaser@41be1e462b (2026-08-13).
Data as JSON: /api/errors/5d0ca2be690900db.
Report an issue: GitHub.