Skip to content

Receiving custom response invokes TypeError in Widget #258

Open
@M1sterShad0w

Description

@M1sterShad0w

I want to create a custom component for handling custom responses that comes in from rasa/botfront but it seems that whenever a custom response comes in, the widget tries to parse it and throws an Uncaught TypeError: can't access property "metadata", e is null or something similar.

It doesn't matter whether I use the widget in a <script> tag or as a react component and whether I actually declare a custom component to handle custom responses or not. The problem is that if I actually use a custom component, the program crashes since the error repeats in an infinite loop - which means that I basically can't handle custom messages.

Since I cannot actually trace the original problem, below is the full stack trace (if it may be of any help - since the code is minified) and the JSON of the response as is shown in the botfront responses:

Stack Trace
Uncaught TypeError: can't access property "metadata", t is null
    value index.js:91
    value index.js:91
    emit index.js:1
    onevent index.js:14
    onpacket index.js:14
    exports index.js:14
    emit index.js:1
    ondecoded index.js:14
    exports index.js:14
    emit index.js:1
    add index.js:7
    ondata index.js:14
    exports index.js:14
    emit index.js:1
    onPacket index.js:89
    setTransport index.js:89
    emit index.js:1
    onPacket index.js:14
    onData index.js:14
    onmessage index.js:91
    addEventListeners index.js:91
    doOpen index.js:91
    open index.js:14
    probe index.js:89
    onOpen index.js:89
    onHandshake index.js:89
    onPacket index.js:89
    setTransport index.js:89
    emit index.js:1
    onPacket index.js:14
    onData index.js:14
    decodePayloadAsBinary index.js:1
    decodePayloadAsBinary index.js:1
    decodePayload index.js:1
    onData index.js:14
    doPoll index.js:89
    emit index.js:1
    onData index.js:89
    onLoad index.js:89
    onreadystatechange index.js:89
    create index.js:89
    l index.js:89
    request index.js:89
    doPoll index.js:89
    poll index.js:14
    doOpen index.js:14
    open index.js:14
    open index.js:89
    l index.js:89
    l index.js:89
    connect index.js:14
    h index.js:14
    h index.js:14
    c index.js:14
    socketio index.js:91
    socket index.js:91
    value index.js:91
    value index.js:91
    value index.js:91
    React 6
        commitLifeCycles
        commitLayoutEffects
        callCallback
        invokeGuardedCallbackDev
        invokeGuardedCallback
        commitRootImpl
    unstable_runWithPriority scheduler.development.js:653
    React 10
        runWithPriority$1
        commitRoot
        finishSyncRender
        performSyncWorkOnRoot
        scheduleUpdateOnFiber
        updateContainer
        legacyRenderSubtreeIntoContainer
        unbatchedUpdates
        legacyRenderSubtreeIntoContainer
        render
    js index.js:39
    Webpack 7
        __webpack_require__
        fn
        1
        __webpack_require__
        checkDeferredModules
        webpackJsonpCallback
        <anonymous>
index.js:91
JSON Response
{
  "event": "bot",
  "timestamp": 1591998655.9789407,
  "text": null,
  "data": {
    "elements": null,
    "quick_replies": null,
    "buttons": null,
    "attachment": null,
    "image": null,
    "custom": {
      "src": "personal_info.birth_date.mp4",
      "room": "c2de63694b39453a9b21bb6bb2480de1"
    }
  },
  "metadata": {}
}

Edit: After a brief investigation it seems that this line is what causes the problem - as for some reason botUtterance is null or undefined and thus it cannot access its metadata, throwing the above error.

Metadata

Metadata

Assignees

Labels

wipWork in progress

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions