Skip to content

Uncaught TypeError: Cannot convert undefined or null to object #490

Closed

Description

@BaoAn21

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

Activity

  1. DKrishna007 commented on Apr 6, 2025

    @DKrishna007

    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!

  2. iwl commented on Apr 22, 2026

    @iwl
    Contributor

    botMessageHandler.handle(JSON.parse(data).status, connection)

    console.log()
    botMessageHandler.handle((data).status, connection)

  3. iwl commented on Apr 24, 2026

    @iwl
    Contributor

    Local NodeWebserverBrowserController updated Node 18-25
    FIX: iwl/OpenBot@ddb6c45 git clone https://github.com/iwl/OpenBot
    OpenBot/controller/node-js npm install npm start
    First connect Browser http://Server:8081 , then OpenBot (close app,retry)
    Works Linux, Win10, Firewall Open tcp 19400 (8081 extern Browser)

  4. thias15 commented on May 9, 2026

    @thias15
    Collaborator

    This is the same bug that PR #511 addresses. The previous code did (data).status which is a no-op cast (data is a string, so .status is undefined), and the downstream Object.keys(undefined) crashed. The fix in #511 parses the message correctly: JSON.parse(data).status.

    Linking to PR #511 so this auto-closes when that lands. Thanks @iwl for the fix and @DKrishna007 for confirming the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions