TencentCloud / TIMSDK

Tencent Cloud Chat features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication.
https://trtc.io/products/chat
2.58k stars 2.76k forks source link

tsignaling 在web端invite报错提示Unexpected end of JSON input的问题 #1134

Closed zionLZH closed 2 years ago

zionLZH commented 2 years ago

【web】-【0.10.0】:tsignaling 在web端invite报错提示Unexpected end of JSON input的问题,经过检查发现系代码中_handleOfflineInfo此处报错

        }, t.prototype._handleOfflineInfo = function (t, e) {
          var i = JSON.parse(t.data), n = {
            action: t.actionType,
            call_type: i.call_type,
            room_id: i.room_id,
            call_id: t.inviteID,
            timeout: i.timeout,
            version: 4,
            invited_list: t.inviteeList
          }

此处的t.data在实际测试中会出现t.data = ''的情况,而JSON.parse('')会导致抛异常提示Uncaught SyntaxError: Unexpected end of JSON input,建议改成JSON.parse(t.data || '{}'),此问题影响集成场景包括trtcCalling,tuiroom等需要在web端集成信令的sdk。