core-js: Map & Set Error in 2.5.3

https://github.com/zloirock/core-js/blob/e1c6719a107b92d21125178b859026a04d5d4686/modules/_iter-define.js#L33

With this code, the code below throw error in Android mobile React-Native jscore.

[...new Map()];
[...new Set()];

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 22 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Same issue here, we were getting Incompatible receiver, Map required in I.E.11. Reverting back to v2.5.2 fixed it. We use core-js via babel-preset-env, in order to get it fixed the solution is to set the version hard in the resolutions property of the package.json file:

"resolutions": {
    "core-js": "2.5.2"
  },

Edit: the resolutions section of the package.json file is a yarn feature!

I put together a few details of another instance of this problem: https://github.com/twilio/TwilioChatJsReactNative/issues/9

If it helps at all, when I turn on react native’s remote debugging, the error goes away. I’m also using android 7.1.1.

I was able to “fix” it in react native by doing this:

yarn add core-js@2.5.2
cp -R node_modules/core-js/* node_modules/fbjs-scripts/node_modules/core-js/
cp -R node_modules/core-js/* node_modules/babel-register/node_modules/core-js/
cp -R node_modules/core-js/* node_modules/babel-runtime/node_modules/core-js/
cp -R node_modules/core-js/* node_modules/metro-bundler/node_modules/core-js/

Ok, I was able to reproduce it… only in FF27. Seems the most cases of this issue was caused conflicts with another not completely correct polyfills. I will revert this change and will publish a patch release soon. This logic will be completely rewritten in core-js@3.

screenshot_2018-08-20-12-34-40-292_com contentstream facing same issue, please provide any information. tried using 2.4.0, 2.5.4 and @3 but not working

By looking at what changes from 2.5.2 to 2.5.3 I narrowed the problem down to this change: https://github.com/zloirock/core-js/issues/236 https://github.com/zloirock/core-js/commit/f96b8d8afaebda5f49ac213627218f841c8692b4#diff-cef85cf90f184a55418f175f3c233f2aR219

If I revert var $default = (!BUGGY && $native) || getMethod(DEFAULT); to var $default = $native || getMethod(DEFAULT); then it works again on Android.

FYI @zloirock

I can confirm React Native breaks for me with 2.5.3 and works again after downgrad to 2.5.2

hi I am using 2.5.4 version in my react-native project. But I am facing this error for android. screenshot_20180329-180410

Can you please advise?

i can reproduce this as well. This occurs on Android API 25, Using Android OS 7.1.1

My RN environment is below.

Environment: OS: macOS High Sierra 10.13.1 Node: 9.2.1 Yarn: Not Found npm: 5.5.1 Watchman: 4.9.0 Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.53.0 => 0.53.0

This is an issue with any RN component that uses virtualized list. They use Maps in the implementation if you are using the onViewableItemsChanged prop of the virtualized list. This then brings the error TaskQueue: Map is Required!

do what @yamafaktory did and downgrading to 2.5.2 worked for me. Clearly an issue is happening with 2.5.3 and React Native specifically

@zloirock This seems to be reproducible with an app that uses jscore (such as React Native) and a babel shimmed for..of block iterating on a Set/Map. This is happening for all versions of Android that I’ve tested.

Debugging this a little bit. Definitely caused by https://github.com/zloirock/core-js/commit/6f9792057de00c873bca6373c1c5eecf66cbc45d. Rolling back to one commit before https://github.com/zloirock/core-js/commit/771b32d5d19e8bf7c292c9f7c9f86deddf755824 and its fine. The stack trace I see is

'TaskQueue: Error with task: Incompatible receiver, Map required! _validate-collection.js:3:55

 if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');<<<<

_collection-strong.js:120:25

    $iterDefine(C, NAME, function (iterated, kind) {
      this._t = validate(iterated, NAME); // target <<<<<<<
      this._k = kind;                     // kind

_iter-define.js:26:57

    switch (kind) {
      case KEYS: return function keys() { return new Constructor(this, kind); };
      case VALUES: return function values() { return new Constructor(this, kind); };
    } return function entries() { return new Constructor(this, kind); }; <<<<<<<

And the react-native code https://github.com/facebook/react-native/blob/master/Libraries/Lists/ViewabilityHelper.js#L249

    const changed = [];
    for (const [key, viewable] of nextItems) { <<<<<<
      if (!prevItems.has(key)) {