Lib-jitsi-meet: conference.leave() leads to: Cannot read properties of null (reading 'myroomjid')

Hello,

we implemented a custom javascript frontend client using lib-jitsi-meet. Everything works, but when leaving a conference in P2P mode we get the following error:

2022-09-17T08:55:38.028Z [modules/xmpp/ChatRoom.js] <Sr.doLeave>:  do leave 624b2184-4976-4eaa-b315-db4dce899022@conference.conference-dev.ches.pro/e30bbc95
TraceablePeerConnection.js:2856 2022-09-17T08:55:38.032Z [modules/RTC/TraceablePeerConnection.js] <Ld.close>:  TPC[id=2,type=P2P] Closing peerconnection
ChatRoom.js:573 2022-09-17T08:55:38.052Z [modules/xmpp/ChatRoom.js] <Sr.onPresence>:  (TIME) MUC join started:	 27642.099999999627
ChatRoom.js:594 2022-09-17T08:55:38.052Z [modules/xmpp/ChatRoom.js] <Sr.onPresence>:  (TIME) MUC joined:	 27642.900000000373
JitsiConference.js:3522 2022-09-17T08:55:38.054Z [JitsiConference.js] <Mh._maybeStartOrStopP2P>:  Will start P2P with: 624b2184-4976-4eaa-b315-db4dce899022@conference.conference-dev.ches.pro/d0fb3a5d
strophe.util.js:89 2022-09-17T08:55:38.055Z [modules/xmpp/strophe.util.js] <ut.Strophe.log>:  Strophe: TypeError: Cannot read properties of null (reading 'myroomjid')
    at Mh._startP2PSession (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:27498:131)
    at Mh._maybeStartOrStopP2P (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:27530:63)
    at Mh._onMucJoined (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:27116:16)
    at r.<anonymous> (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:13054:29)
    at r.emit (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:6572:37)
    at Sr.onPresence (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:15646:180)
    at Er.onPresence (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:16173:147)
    at I.Handler.run (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:9225:26)
    at http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:9471:75
    at Object.forEachChild (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:8947:87)
    at I.Connection._dataRecv (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:9463:21)
    at O.Websocket._onMessage (http://localhost:4200/ches-main_app_modules_video-conference_video-conference_module_ts.js:10223:283)
    at WebSocket.wrapFn (http://localhost:4200/polyfills.js:9265:35)
    at _ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:8824:171)
    at Object.onInvokeTask (http://localhost:4200/vendor.js:153974:25)
    at _ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:8824:54)
    at Zone.runTask (http://localhost:4200/polyfills.js:8585:37)
    at ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.js:8916:26)
    at invokeTask (http://localhost:4200/polyfills.js:10343:12)
    at globalCallback (http://localhost:4200/polyfills.js:10380:21)
    at WebSocket.globalZoneAwareCallback (http://localhost:4200/polyfills.js:10415:12)
strophe.util.js:89 2022-09-17T08:55:38.056Z [modules/xmpp/strophe.util.js] <ut.Strophe.log>:  Strophe: error: Cannot read properties of null (reading 'myroomjid')
strophe.util.js:76 2022-09-17T08:55:38.056Z [modules/xmpp/strophe.util.js] <ut.Strophe.log>:  Strophe: Removing Strophe handlers due to uncaught exception: Cannot read properties of null (reading 'myroomjid')
BridgeChannel.js:429 2022-09-17T08:55:38.077Z [modules/RTC/BridgeChannel.js] <e.onclose [as __zone_symbol__ON_PROPERTYclose]>:  Channel closed by client

I also check with the native jitsi-meet frontend and in comparison to our own log I see the TraceablePeerConnection#close() call twice, calling a JVB type and P2P type connection:

2022-09-17T08:13:54.964Z [modules/xmpp/ChatRoom.js] <Sr.doLeave>:  do leave 624b2184-4976-4eaa-b315-db4dce899022@conference.conference-dev.ches.pro/4356f748
Logger.js:154 2022-09-17T08:13:54.983Z [modules/RTC/TraceablePeerConnection.js] <Ld.close>:  TPC[id=2,type=JVB] Closing peerconnection
Logger.js:154 2022-09-17T08:13:54.999Z [modules/RTC/TraceablePeerConnection.js] <Ld.close>:  TPC[id=1,type=P2P] Closing peerconnection
Logger.js:154 2022-09-17T08:13:55.017Z [features/base/redux] <Object.persistState>:  redux state persisted. eeb5acb51d32c05bc38d45688b6de3b4 -> edd585582b490b2e2dce1475b0e677a5
Logger.js:154 2022-09-17T08:13:55.066Z [modules/RTC/BridgeChannel.js] <e.onclose>:  Channel closed by client

My code for leaving a confernce is:

  1. Await disposing local tracks
  2. Await leaving the conference
  3. Await disconnecting from server
Promise.all(afterDisposed).finally(() => {
      if (this.conference) {
        this.conference
          .leave()
          .then(() => {
            this.connection
              .disconnect()
              .then(() => {
                ...

According to the browser log, in our implemation we receive MUC joined… events, that trigger the maybeStartOrStopP2P function. What am I missing when leaving a conference?
This happens only if the conference is in P2P mode.