JsSIP icon indicating copy to clipboard operation
JsSIP copied to clipboard

Circular dependency causes "TypeError: Cannot read property 'STATUS_TERMINATED' of undefined"

Open alexsharabaykoidt opened this issue 4 years ago • 1 comments

Versions: 3.7.0 - 3.7.5 (at least)

The library build has circular dependency: ./UA -> ./RTCSession -> ./Dialog -> ./Dialog/RequestSender -> ../RTCSession

Thus RTCSession is empty object inside Dialog/RequestSender and it doesn't have C (constants) property. And then when 491 status comes RTCSession.C.STATUS_TERMINATED cannot be executed without TypeError.

image

So i see two ways how to fix it:

  1. Resolve circular dependency
  2. Import RTCSession every time before its usage

alexsharabaykoidt avatar Apr 22 '21 15:04 alexsharabaykoidt

  1. Import RTCSession every time before its usage

Dynamic import is anti-pattern and does not work when using ES6 import (we'll migrate to that eventually).

  1. Resolve circular dependency

Can you contribute with a PR?

ibc avatar Apr 22 '21 15:04 ibc