versatica / mediasoup

Cutting Edge WebRTC Video Conferencing

Home Page:https://mediasoup.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong handle of response in Channel.ts?

webRTCv1 opened this issue · comments

Bug Report

Your environment

  • Operating system: Linux 22.04 LTS
  • Node version: v18.17.1
  • npm version: 9.6.7
  • gcc/clang version:
  • mediasoup version: 3.13.19
  • mediasoup-client version: 3.7.2

Issue description

We got this message on Sentry, maybe related to wrong handle of response in Channel.ts?

error

We encountering an issue where the response object doesn't have the expected reason() method, you might want to verify the structure of the response object.

Maybe the fix can be something like:

	private processResponse(response: Response): void {
		const sent = this.#sents.get(response.id);

		if (!sent) {
			logger.error(
				`received response does not match any sent request [id:${response.id}]`
			);

			return;
		}

		if (response.accepted) {
			logger.debug(`request succeeded [method:${sent.method}, id:${sent.id}]`);

			sent.resolve(response);
		} else if (response.error) {
			logger.warn(
				`request failed [method:${sent.method}, id:${
					sent.id
				}]: ${response.reason}`
			);

			switch (response.error) {
				case 'TypeError': {
					sent.reject(new TypeError(response.reason));

					break;
				}

				default: {
					sent.reject(new Error(response.reason));
				}
			}
		} else {
			logger.error(
				`received response is not accepted nor rejected [method:${sent.method}, id:${sent.id}]`
			);
		}
	}

Here, we're assuming response.reason directly holds the error message, same for

  • response.id
  • response.error

If this is not a mediasoup issue, forgive us! We will ask maybe in the forum...

Thank you!

Where exactly do you see that such a response doesn't have error()?

Your app is calling consumer.setPreferredLayer() on a Consumer that no longer exists (it's closed). That's all. Nothing else is suspicious in the Sentry report you show above. The error is indeed there: "Channel request handler with ID xxxxx not found", which means exactly that and obviously has a reason() which is "Channel request handler with ID xxxxx not found".

I'm closing this issue, but if I'm missing something please comment and will reopen if there is a real bug in mediasoup side.