Luligu / matterbridge

Matterbridge plugin manager for Matter
https://github.com/Luligu/matterbridge/blob/main/README.md
Apache License 2.0
125 stars 13 forks source link

Startup crash with 1.3.5+ #71

Closed genehand closed 2 weeks ago

genehand commented 2 weeks ago

Hey I'm getting startup crashes with the latest releases, going back to 1.3.4 resolves it:

Jun 30 08:16:32 chip matterbridge[6899]: [08:16:32.575] [Matterbridge] Matter server started
Jun 30 08:16:32 chip matterbridge[6899]: [08:16:32.576] [Matterbridge] The commissioning server on port 5541 for matterbridge-zigbee2mqtt is already commissioned. Waiting for controllers to connect ...
Jun 30 08:16:32 chip matterbridge[6899]: [08:16:32.576] [Matterbridge] Commissioned fabric information:
Jun 30 08:16:32 chip matterbridge[6899]: [08:16:32.576] [Matterbridge] - fabric index 1 id <snip> vendor 4631 (Alexa) Alexa-1
Jun 30 08:16:32 chip matterbridge[6899]: /usr/lib/node_modules/matterbridge/node_modules/node-persist/src/local-storage.js:449
Jun 30 08:16:32 chip matterbridge[6899]:        return this.options.stringify(obj);
Jun 30 08:16:32 chip matterbridge[6899]:                            ^
Jun 30 08:16:32 chip matterbridge[6899]: TypeError: Do not know how to serialize a BigInt
Jun 30 08:16:32 chip matterbridge[6899]:     at Object.stringify (<anonymous>)
Jun 30 08:16:32 chip matterbridge[6899]:     at LocalStorage.stringify (/usr/lib/node_modules/matterbridge/node_modules/node-persist/src/local-storage.js:449:23)
Jun 30 08:16:32 chip matterbridge[6899]:     at LocalStorage.copy (/usr/lib/node_modules/matterbridge/node_modules/node-persist/src/local-storage.js:469:26)
Jun 30 08:16:32 chip matterbridge[6899]:     at LocalStorage.setItem (/usr/lib/node_modules/matterbridge/node_modules/node-persist/src/local-storage.js:179:20)
Jun 30 08:16:32 chip matterbridge[6899]:     at NodeStorage.set (file:///usr/lib/node_modules/matterbridge/node_modules/node-persist-manager/dist/nodeStorage.js:148:35)
Jun 30 08:16:32 chip matterbridge[6899]:     at Matterbridge.showCommissioningQRCode (file:///usr/lib/node_modules/matterbridge/dist/matterbridge.js:1969:37)
Jun 30 08:16:32 chip matterbridge[6899]:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Jun 30 08:16:32 chip matterbridge[6899]:     at async Timeout.<anonymous> (file:///usr/lib/node_modules/matterbridge/dist/matterbridge.js:1799:21)

After getting that it then can't restart at all:

Jun 30 08:17:23 chip matterbridge[7099]: CLI: Matterbridge.loadInstance() failed with error: Error: [node-persist][readFile] /home/mb/.matterbridge/storage/.matterbridge/c6724947ca70506d3d4794dd710813af1a1ef8e646852dba3fe0dea6a2aa7911 does not look like a valid storage file!

The file is 0 bytes, after deleting it and going back to 1.3.4 it contains:

{"key":"matterbridgeLatestVersion","value":"1.3.7"}

I'm running in childbridge mode with the latest matterbridge-zigbee2mqtt (2.1.4) and matterbridge-home-assistant (1.3.6) plugins. I don't see any obvious BigInt changes, let me know any other info you need.

Apollon77 commented 2 weeks ago

Interesting ... but yes bigint is not handled by JSON.stringify by default ... @Luligu We have extra stiff in matter,js to stringify correctly including bigint

Luligu commented 2 weeks ago

Hi, thanks for letting me know. Fixed with

[1.3.8] - 2024-07-01

Fixed

@Apollon77 thanks me too of course but the problem is express. I will sanitize fabricInfo.

genehand commented 2 weeks ago

All good here again with 1.3.8, thx!

Luligu commented 2 weeks ago

Great! Thanks again.