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

Map & Set Error in 2.5.3 #368

Closed
xupaopaopaopao opened this issue Dec 15, 2017 · 22 comments
Closed

Map & Set Error in 2.5.3 #368

xupaopaopaopao opened this issue Dec 15, 2017 · 22 comments
Labels

Comments

@xupaopaopaopao
Copy link

var $default = (!BUGGY && $native) || getMethod(DEFAULT);

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

[...new Map()];
[...new Set()];
@zloirock
Copy link
Owner

I'm not completely sure how it can break something. What's the version of Android? Is spread operator native or from Babel?

@chrisnojima
Copy link

I believe we ran into this as well. Using chrome its fine but on device our android crashes after going from 2.5.1 -> 2.5.3

@zloirock
Copy link
Owner

So... Any additional information?

@chrisnojima
Copy link

Debugging this a little bit. Definitely caused by 6f97920. Rolling back to one commit before 771b32d 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)) {

@yamafaktory
Copy link

yamafaktory commented Dec 19, 2017

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!

@SinLucifer
Copy link

There is a js file named BackHandler.Android.js in React-Native, which is used to manage Android BackPress Events.

var _backPressSubscriptions = new Set();
RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function() {
  var backPressSubscriptions = new Set(_backPressSubscriptions);
  var invokeDefault = true;
  var subscriptions = [...backPressSubscriptions].reverse();
  for (var i = 0; i < subscriptions.length; ++i) {
    if (subscriptions[i]()) {
      invokeDefault = false;
      break;
    }
  }

Because of this code var subscriptions = [...backPressSubscriptions].reverse(); and Map&Set Error, when we press BackPress in Android, it will lead these execption:

image

Reverting back to v2.5.2 fixed this problem.

@nevir
Copy link

nevir commented Dec 26, 2017

Also see this when running Array.from(new Set([1, 2, 3])) on RN-android

@ttaranov
Copy link

ttaranov commented Jan 3, 2018

run into a related issue I think - although in IE11 and in dev mode with babel, for loops like like
for (const [k, v] of myMap) {
}
produces (sometimes): "Incompatible receiver, Map required!"

downgrading to 2.5.2 fixes IE errors

@loganfsmyth
Copy link
Contributor

If you're seeing this, please take a minute to put together a reproducible example repository that contains code that reproduces the error, it would help a ton in narrowing this down.

@zloirock
Copy link
Owner

zloirock commented Jan 3, 2018

IE11:
image
Android 4.4-6:
image
image
image
image
So what about a reproducible example and clarification your environment?

@lwansbrough
Copy link

lwansbrough commented Jan 22, 2018

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

@davidpricedev
Copy link

I put together a few details of another instance of this problem: twilio/TwilioChatJsReactNative#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 [email protected]
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/

@philipyun
Copy link

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

@nandowalter
Copy link

I can confirm that this error occurs also with an Angular 5 project using core-js polyfills.

@forki
Copy link

forki commented Mar 2, 2018

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

@skovhus
Copy link

skovhus commented Mar 7, 2018

By looking at what changes from 2.5.2 to 2.5.3 I narrowed the problem down to this change: #236 f96b8d8#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

@zloirock
Copy link
Owner

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.

zloirock added a commit that referenced this issue Mar 22, 2018
zloirock added a commit that referenced this issue Mar 22, 2018
@skovhus
Copy link

skovhus commented Mar 22, 2018

@zloirock thanks!

@forki
Copy link

forki commented Mar 22, 2018 via email

zloirock added a commit that referenced this issue Mar 27, 2018
zloirock added a commit that referenced this issue Mar 27, 2018
zloirock added a commit that referenced this issue Mar 27, 2018
@zloirock
Copy link
Owner

Fixed in 2.5.4 and 3.0.0-alpha.1.

@ghost
Copy link

ghost commented Mar 29, 2018

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?

@ghost ghost mentioned this issue Apr 3, 2018
zloirock added a commit that referenced this issue Apr 3, 2018
zloirock added a commit that referenced this issue Apr 9, 2018
zloirock added a commit that referenced this issue Apr 9, 2018
zloirock added a commit that referenced this issue Apr 21, 2018
zloirock added a commit that referenced this issue May 4, 2018
zloirock added a commit that referenced this issue May 5, 2018
zloirock added a commit that referenced this issue May 5, 2018
zloirock added a commit that referenced this issue May 7, 2018
zloirock added a commit that referenced this issue May 7, 2018
zloirock added a commit that referenced this issue May 14, 2018
zloirock added a commit that referenced this issue May 14, 2018
zloirock added a commit that referenced this issue May 18, 2018
zloirock added a commit that referenced this issue May 26, 2018
zloirock added a commit that referenced this issue May 26, 2018
zloirock added a commit that referenced this issue May 26, 2018
@kalyanijamunkar10
Copy link

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

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

No branches or pull requests