# Replacing a config-node crashes NR

**URL:** <https://discourse.nodered.org/t/replacing-a-config-node-crashes-nr/84976>\
**Category:** Core Development\
**Created:** [27 January 2024 18:33 UTC](https://discourse.nodered.org/t/replacing-a-config-node-crashes-nr/84976 "2024-01-27T18:33:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [27 January 2024 18:33 UTC](https://discourse.nodered.org/t/replacing-a-config-node-crashes-nr/84976/1 "2024-01-27T18:33:00Z")

</div>

Hi All,

I have a bit of a strange bug and I don't know where it comes from.

If I start NR with a missing config-node type, the editor shows me the `unknown` type for this config-node. Normal so far.

If I import a config-node with the same id and the right type (which exists), and I replace it, the editor seems to have done its job but when I deploy with `Modified Nodes` I get the following error:

```auto
27 Jan 19:05:02 - [info] En attente d'enregistrement des types manquants :
27 Jan 19:05:02 - [info] - database-config
27 Jan 19:05:02 - [info] Le serveur est disponible à l'adresse http://127.0.0.1:1880/
27 Jan 19:05:55 - [info] Arrêt des noeuds modifiés
27 Jan 19:05:55 - [info] Noeuds modifiés arrêtés
27 Jan 19:05:55 - [info] Flux mis à jour
27 Jan 19:06:08 - [info] Démarrage des noeuds modifiés
27 Jan 19:06:54 - [red] Uncaught Exception:
27 Jan 19:06:54 - [error] TypeError: Cannot read properties of undefined (reading 'update')
    at start (/usr/local/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/index.js:377:31)

```

If I look in the runtime, `activeFlows` is an empty object, so:

```js
activeFlows['global'].update(activeFlowConfig,activeFlowConfig);

```

throw the error.

Note: A full deployment does not have this problem.

To reproduce this behavior:

- Stop NR
- Modify the `flows.json` file by changing the type of a config node
- Start NR
- Import this node with it's original type
- Replace it
- Deploy with `Modified Nodes`

Do you also have this behavior?

Thanks

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [27 January 2024 21:35 UTC](https://discourse.nodered.org/t/replacing-a-config-node-crashes-nr/84976/2 "2024-01-27T21:35:45Z")

</div>

If you can reliably recreate it, please raise an issue with these details.

I could well imagine that importing a replacement node whilst its type is unknown would be an untested scenario.

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [28 January 2024 08:40 UTC](https://discourse.nodered.org/t/replacing-a-config-node-crashes-nr/84976/3 "2024-01-28T08:40:09Z")

</div>

I think I put everything in.

> <https://github.com/node-red/node-red/issues/4548>
>
> \### Current Behavior
> 
> If I start Node-RED with a missing \*\*config-node\*\* type, t…he editor shows me the \`unknown\` type for that config-node. Normal so far.
> 
> If I import this same config-node with the correct type (which exists), and replace it, the editor seems to have done its job but when I deploy with \`Modified Nodes\`, I get the following error:
> 
> \`\`\`txt
> 27 Jan 19:05:02 - \[info\] En attente d'enregistrement des types manquants :
> 27 Jan 19:05:02 - \[info\] - database-config
> 27 Jan 19:05:02 - \[info\] Le serveur est disponible à l'adresse http://127.0.0.1:1880/
> 27 Jan 19:05:55 - \[info\] Arrêt des noeuds modifiés
> 27 Jan 19:05:55 - \[info\] Noeuds modifiés arrêtés
> 27 Jan 19:05:55 - \[info\] Flux mis à jour
> 27 Jan 19:06:08 - \[info\] Démarrage des noeuds modifiés
> 27 Jan 19:06:54 - \[red\] Uncaught Exception:
> 27 Jan 19:06:54 - \[error\] TypeError: Cannot read properties of undefined (reading 'update')
> at start (/usr/local/lib/node\_modules/node-red/node\_modules/@node-red/runtime/lib/flows/index.js:377:31)
> \`\`\`
> 
> If I look in the runtime, \`activeFlows\` is an empty object, so:
> 
> \`\`\`js
> activeFlows\['global'\].update(activeFlowConfig,activeFlowConfig);
> \`\`\`
> 
> throws the error.
> 
> Note: I didn't notice this error with a full deploy but \`activeFlows\` is empty when \`setFlows\` is called.
> 
> I also notice that if I import directly the wrong config-node (without modifying the file) then replace it with the correct one and deploy, I have no problems.
> 
> But if I try with a \*\*node\*\*, the editor does not handle it: the editor shows me the \`unknown\` type for this node and when I import this node with the right type, I cannot replace it (even if I force it from the console).
> 
> 
> \### Expected Behavior
> 
> Handle the replacement of an unknown node with the correct one.
> Whether it's a node or a config-node.
> 
> Note: number of users in config-node is not updated after import.
> 
> \### Steps To Reproduce
> 
> For config-node:
> \- Stop NR
> \- Modify the flows.json file by changing the type of a config-node
> \- Start NR
> \- Import this node with it's original type
> \- Replace it
> \- Deploy with Modified Nodes
> 
> For node:
> \- Stop NR
> \- Modify the flows.json file by changing the type of a node
> \- Start NR
> \- Import this node with it's original type
> 
> \### Example flow
> 
> Add this fake \`mqtt-broker\` config-node to your \`flows.json\` file:
> 
> \`\`\`json
> \[
> {
> "id": "1deb012b34859b46",
> "type": "bad-mqtt-broker",
> "name": "Config Node Test",
> "broker": "localhost",
> "port": "1883",
> "clientid": "",
> "autoConnect": true,
> "usetls": false,
> "protocolVersion": "4",
> "keepalive": "60",
> "cleansession": true,
> "autoUnsubscribe": true,
> "birthTopic": "",
> "birthQos": "0",
> "birthRetain": "false",
> "birthPayload": "",
> "birthMsg": {},
> "closeTopic": "",
> "closeQos": "0",
> "closeRetain": "false",
> "closePayload": "",
> "closeMsg": {},
> "willTopic": "",
> "willQos": "0",
> "willRetain": "false",
> "willPayload": "",
> "willMsg": {},
> "userProps": "",
> "sessionExpiry": ""
> }
> \]
> \`\`\`
> 
> Now replace it with the correct one in the editor:
> 
> \`\`\`json
> \[
> {
> "id": "1deb012b34859b46",
> "type": "mqtt-broker",
> "name": "Config Node Test",
> "broker": "localhost",
> "port": "1883",
> "clientid": "",
> "autoConnect": true,
> "usetls": false,
> "protocolVersion": "4",
> "keepalive": "60",
> "cleansession": true,
> "autoUnsubscribe": true,
> "birthTopic": "",
> "birthQos": "0",
> "birthRetain": "false",
> "birthPayload": "",
> "birthMsg": {},
> "closeTopic": "",
> "closeQos": "0",
> "closeRetain": "false",
> "closePayload": "",
> "closeMsg": {},
> "willTopic": "",
> "willQos": "0",
> "willRetain": "false",
> "willPayload": "",
> "willMsg": {},
> "userProps": "",
> "sessionExpiry": ""
> }
> \]
> \`\`\`
> 
> 
> \### Environment
> 
> \- Node-RED version: v3.1.3
> \- Node.js version: v20.10.0
> \- npm version: v10.2.3
> \- Platform/OS: MacOS
> \- Browser: Safari

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 March 2024 08:40 UTC](https://discourse.nodered.org/t/replacing-a-config-node-crashes-nr/84976/4 "2024-03-28T08:40:14Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
