Uncaught TypeError: Cannot convert undefined or null to object
Describe the bug
I use node-js controller, after running npm start and connect to OpenBot on Android, with WebRTC streaming, I got error Uncaught TypeError: Cannot convert undefined or null to object
Screenshots
Desktop (please complete the following information):
- OS: MacOS
- Browser chrome
Smartphone (please complete the following information):
- Device: Samsung A06
- OS: Android 14
That error – Uncaught TypeError: Cannot convert undefined or null to object – usually means the app is trying to run Object.keys() on something that’s either undefined or null.
It looks like this is happening in bot-message-handler.js around line 20. Probably some unexpected or malformed data is coming in over the WebRTC connection.
You can add a quick check before using Object.keys() to make sure the message is actually valid!
if (message && typeof message === 'object') { Object.keys(message).forEach((key) => { // your existing logic }); } else { console.warn("Received invalid message:", message); } That should stop the crash and help catch any weird messages for debugging.
Let me know if that works or if you'd like me to send a quick PR with the fix!