Skip to content

Strophe hides errors in a try..catch block then removes all of its handlers leading to unexpected behavior #29

@fc

Description

@fc

Steps to reproduce the error modifying the main.js in your peer-to-peer example.

  1. Add this line in the QB.webrtc.onRejectCallListener callback function:
  throw "We have an error!";
  1. Now, call someone using the peer-to-peer code.
  2. When there is an incoming call click 'Reject'
  3. This will work correctly the first time but Strophe's handlers are removed when this happens. The exception thrown slips by unnoticed.
  4. Call that same person again (don't reload the browsers)
  5. Click 'Reject' again
  6. When you're clicking Reject now, it won't correctly send the message to QuickBlox to handle the reject response.
  7. It goes into an infinite loop where you keep clicking Reject ad infinitum.

I had an undefined variable in the onRejectCallListener but the error gets trapped within Strophe's try...catch block and it never gets reported to QuickBlox.

The big issue is that Strophe suddenly removes all of its handlers.

TypeError: Cannot read property 'full_name' of undefined
    at WebRTCProxy.QB.webrtc.onRejectCallListener (http://www.domain.com/assets/js/chat/main.js:283:93)
    at Object.8.conn._onMessage [as handler] (http://www.domain.com/assets/js/quickblox/quickblox.js:1920:14)
    at Object.15.h.Handler.run (http://www.domain.com/assets/js/quickblox/quickblox.js:3041:16841)
    at http://www.domain.com/assets/js/quickblox/quickblox.js:3041:24530
    at Object.15.h.forEachChild (http://www.domain.com/assets/js/quickblox/quickblox.js:3041:9327)
    at Object.15.h.Connection._dataRecv (http://www.domain.com/assets/js/quickblox/quickblox.js:3041:24363)
    at Object.15.a.Websocket._onMessage (http://www.domain.com/assets/js/quickblox/quickblox.js:3042:18519)"
VM1936:1 2 "Removing Strophe handlers due to uncaught exception: Cannot read property 'full_name' of undefined"

Well.. removing the invalid code fixed my problem. if anyone else runs into unexpected behavior, turn on Strophe's logging for yourself.

Strophe.log = function(level, msg) { console.log(level, msg); };

And, if you put in a try...catch around all your callbacks you can trap these kind of errors so Strophe doesn't remove its handlers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions