Error in mediaCapturePermission API: `TypeError: Cannot read properties of undefined (reading 'caps')`

Description
Sometimes, the recording request modal may not appear and following error is thrown in mediaCapturePermission.

TypeError: Cannot read properties of undefined (reading 'caps')

Browser Console Error
The code repeatedly runs mediaCapturePermission until it succeeds, but many times it fails with the following error.

stack: [
0: "TypeError: Cannot read properties of undefined (reading 'caps')"
1: "    at <anonymous> (http://localhost:8080/zoom/meeting.js:136:10)"
2: "    at singleRequestMediaCapturePermission (http://localhost:8080/zoom/meeting.js:142:16)"
3: "    at mediaCapturePermission (https://source.zoom.us/zoom-meeting-2.15.2.min.js:1:4133718)"
4: "    at Z (https://source.zoom.us/zoom-meeting-2.15.2.min.js:1:4115438)"
5: "    at C (https://source.zoom.us/zoom-meeting-2.15.2.min.js:1:4162226)"
6: "    at value (https://source.zoom.us/zoom-meeting-2.15.2.min.js:1:4082259)"
7: "    at Mt (https://source.zoom.us/zoom-meeting-2.15.2.min.js:1:3922839)"
]

Which Web Meeting SDK version?
2.15.2

Meeting SDK Code Snippets

ZoomMtg.join({
  ...
  success: () => {
     requestMediaCapturePermission()
     ...
  }
});

let intervalId = null;
function requestMediaCapturePermission() {
  singleRequestMediaCapturePermission();
  if (intervalId !== null) {
    clearInterval(intervalId);
  }
  intervalId = setInterval(() => {
    singleRequestMediaCapturePermission();
  }, 15000);
}

function singleRequestMediaCapturePermission() {
  console.log('mediaCapturePermission request');
  ZoomMtg.mediaCapturePermission({
    operate: 'request',
    error: ({errorCode, errorMessage}) => {
      console.log(
        'mediaCapturePermission error',
        errorCode,
        errorMessage
      );
      if (errorMessage === 'you already have local record permission') {
        mediaCapture('start');
        console.log('Media capture permission changed to ALLOW');
        clearInterval(intervalId);
      }
    },
    success: () => {
      console.log('mediaCapturePermission success');
    },
  });
}    

To Reproduce(If applicable)
Steps to reproduce the behavior:

  1. turn on “Local Recording” in setting page
  2. the host(human) starts a meeting in zoom native app 5.15.7 (21404)
  3. the bot (above snippets) joins the meeting
  4. sometimes, the recording request modal doesn’t appear, and above console error is thrown.

Screenshots
If applicable, add screenshots to help explain your problem.

Troubleshooting Routes
The troubleshooting attempt types you’ve already exhausted, including testing with the appropriate sample app (found on Zoom · GitHub).

Device (please complete the following information):

  • Device: GCE instance
  • OS: Ubuntu 22.04
  • Browser: chrome
  • Browser Version: google-chrome-stable_108.0.5359.124-1

Additional context

Hey @kanata.koyama, I’m happy to help! We work extensively with the Zoom Web SDK to build bots, and this is an error we’ve encountered before.

Unfortunately this is a bug in the Zoom SDK itself. If you’re seeing this happen for the first invocation of the function, in my experience that means there is likely a race condition occurring where the “ZoomMtg.mediaCapturePermission” function is trying to access some meeting metadata before that metadata has been populated from the bot joining the call.

You can add a delay to the “requestMediaCapturePermission” function so it runs a few hundred milliseconds after the “success” callback, which should give the data more time to populate.

An alternative is to use the recall.ai API, which is a service for hosted meeting bots. That means you get a simple API to add bots to calls and you don’t need to worry about developing the bots or running the infrastructure.

1 Like

thank you for reply :cry: :bowing_man:

You can add a delay to the “requestMediaCapturePermission” function so it runs a few hundred milliseconds after the “success” callback, which should give the data more time to populate.

thanks!!
i’ll check it soon!!!

An alternative is to use the recall.ai API, which is a service for hosted meeting bots. That means you get a simple API to add bots to calls and you don’t need to worry about developing the bots or running the infrastructure.

It looks very attractive… haha

@amanda-recallai
I have one question.
Within the requestMediaCapturePermission, mediaCapturePermission is called many times every 15sec, so there is already enough delay after the second time.
Therefore, I don’t think I can get around it that way, am I wrong?

You can add a delay to the “requestMediaCapturePermission” function so it runs a few hundred milliseconds after the “success” callback, which should give the data more time to populate.

Hey @kanata.koyama if you’re seeing this happen on the 2nd or later invocations, you may be running into a different error than the one I was originally describing!

To make sure I understand the situation correctly, which of the following situations describes what you’re seeing?

  1. The error occurs sporadically: meaning that calling requestMediaCapturePermission will fail occasionally but will succeed when retried.
  2. The error occurs consistently: meaning that most bots never run into this exception, but some bots always run into this exception when calling requestMediaCapturePermission and the function never succeeds for those bots even if retried.

I’d also be happy to jump on a quick call to help you figure this out!

1 Like

thank you for reply!
we are facing to the situation 2.

“The error occurs consistently”

Hmm, we’ve only seen this specific error happen consistently when the host is not present in the meeting. This can happen if you have a scheduled meeting set up so anyone can join before the host, and the bot has joined before the host has.

This bug occurs because the Zoom Web SDK requires the host to be in the meeting for the permission request to work, and if the host is not in the meeting this error will be raised.

Could this possibly be the case? I’d also be happy to get on a Zoom call to debug this with you if you’re open to it.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.