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

**URL:** <https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683>\
**Category:** Web\
**Created:** [October 12, 2023, 12:55pm UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683 "2023-10-12T12:55:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanata.koyama](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kanata.koyama/32/45206_2.png) [@kanata.koyama](https://devforum.zoom.us/u/kanata.koyama)\
**Post date:** [October 12, 2023, 12:55pm UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/1 "2023-10-12T12:55:04Z")

</div>

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

```auto
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.

```auto
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**

```auto
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](https://github.com/zoom)).

**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**

---

<div class="post-metadata">

**Author:** ![amanda-recallai](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/amanda-recallai/32/44747_2.png) [@amanda-recallai](https://devforum.zoom.us/u/amanda-recallai)\
**Post date:** [October 13, 2023, 6:20am UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/2 "2023-10-13T06:20:50Z")

</div>

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](https://www.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.

---

<div class="post-metadata">

**Author:** ![kanata.koyama](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kanata.koyama/32/45206_2.png) [@kanata.koyama](https://devforum.zoom.us/u/kanata.koyama)\
**Post date:** [October 13, 2023, 8:19am UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/3 "2023-10-13T08:19:16Z")

</div>

thank you for reply 😢 🙇‍♂️

> 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](https://www.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

---

<div class="post-metadata">

**Author:** ![kanata.koyama](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kanata.koyama/32/45206_2.png) [@kanata.koyama](https://devforum.zoom.us/u/kanata.koyama)\
**Post date:** [October 13, 2023, 9:28am UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/4 "2023-10-13T09:28:35Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![amanda-recallai](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/amanda-recallai/32/44747_2.png) [@amanda-recallai](https://devforum.zoom.us/u/amanda-recallai)\
**Post date:** [October 15, 2023, 7:22am UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/5 "2023-10-15T07:22:49Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kanata.koyama](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/kanata.koyama/32/45206_2.png) [@kanata.koyama](https://devforum.zoom.us/u/kanata.koyama)\
**Post date:** [October 16, 2023, 1:55am UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/6 "2023-10-16T01:55:55Z")

</div>

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

> “The error occurs consistently”

---

<div class="post-metadata">

**Author:** ![amanda-recallai](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/amanda-recallai/32/44747_2.png) [@amanda-recallai](https://devforum.zoom.us/u/amanda-recallai)\
**Post date:** [October 20, 2023, 6:07am UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/7 "2023-10-20T06:07:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [November 19, 2023, 4:07pm UTC](https://devforum.zoom.us/t/error-in-mediacapturepermission-api-typeerror-cannot-read-properties-of-undefined-reading-caps/96683/8 "2023-11-19T16:07:45Z")

</div>

Closed on November 19, 2023, 4:07pm UTC

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