Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: sdp.media[Symbol.iterator] is not a function #60

Closed
mkjiau opened this issue Dec 4, 2018 · 2 comments
Closed

Uncaught TypeError: sdp.media[Symbol.iterator] is not a function #60

mkjiau opened this issue Dec 4, 2018 · 2 comments

Comments

@mkjiau
Copy link

mkjiau commented Dec 4, 2018

There's a transpiler issue that failed to transpile codes into lib-es5.

For instance, in line 21 of lib/handlers/sdp/commonUtils.js:

for (const m of sdpObj.media) { ...

transpiled to:

for (var _iterator = sdpObj.media[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { ...

it will throw Uncaught TypeError: sdp.media[Symbol.iterator] is not a function as Iteration_protocols, pure js object is not iterable.

The best way to solve it is to refactor the codebases by replacing

for (const m of sdpObj.media) { ...`

with

for (const m of Object.values(sdpObj.media)) { ...` 

for reference: babel/babel-loader#84

BTW, I'm working on React-Native with mediasoup-client, the workaround to this issue just changes the nodejs entrypoint from "lib-es5/index.js" to "lib/index.js" as package.json below:

  ...
  "homepage": "https://mediasoup.org",
  "license": "ISC",
  "main": "lib/index.js",
  "name": "mediasoup-client",
  ...

any suggestion? mediasoup is great 👍

@ibc
Copy link
Member

ibc commented Dec 4, 2018

The best way to solve it is to refactor the codebases by replacing

for (const m of sdpObj.media) { ...`

with

for (const m of Object.values(sdpObj.media)) { ...` 

This is wrong. sdpObj.media is an Array and not an Object, so using Object.values(sdpObj.media) does not make sense. The issue is elsewhere.

for reference: babel/babel-loader#84

BTW, I'm working on React-Native with mediasoup-client, the workaround to this issue just changes the nodejs entrypoint from "lib-es5/index.js" to "lib/index.js" as package.json below:

  ...
  "homepage": "https://mediasoup.org",
  "license": "ISC",
  "main": "lib/index.js",
  "name": "mediasoup-client",
  ...

I'd like to move main to point to the untranspiled entry point (lib/index.js). However, have you tested that it still works in Chrome, Firefox and Safari that way?

@ibc
Copy link
Member

ibc commented Dec 5, 2018

BTW, in mediasoup v3 package.json will no longer export a ES5 transpiled/babelized version, so "main" will point to the ES6 lib/ folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants