OpenBot icon indicating copy to clipboard operation
OpenBot copied to clipboard

Uncaught TypeError: Cannot convert undefined or null to object

Open BaoAn21 opened this issue 10 months ago • 1 comments

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

Image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser chrome

Smartphone (please complete the following information):

  • Device: Samsung A06
  • OS: Android 14

BaoAn21 avatar Mar 31 '25 14:03 BaoAn21

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!

DKrishna007 avatar Apr 06 '25 05:04 DKrishna007