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

[Modern] RN - working only when debugging remotely #1704

Closed
ukasiu opened this issue Apr 27, 2017 · 9 comments
Closed

[Modern] RN - working only when debugging remotely #1704

ukasiu opened this issue Apr 27, 2017 · 9 comments

Comments

@ukasiu
Copy link

ukasiu commented Apr 27, 2017

Hi,
I'm playing with Relay Modern on React Native. It doesn't pass props down when running normally (though requests are made), it does only when I switch to debugging in browser (though request are still made from the device).

@gusbicalho
Copy link

Not sure it's the same problem from what you've said, but probably related to this: zloirock/core-js#297
At some point the runtime checks if pendingQueries.size is truthy, but the Set polyfill use by relay returns undefined on android (yeah, wtf). I've submitted a PR fixing it, but it hasn't been accepted yet.

Meanwhile, adding the code below fixed it for me:

(function(PolyfillSet) {
  if (!PolyfillSet) {
    return;
  }
  var testSet = new PolyfillSet();
  if (testSet.size === undefined) {
    if (testSet._c.size === 0) {
      Object.defineProperty(PolyfillSet.prototype, 'size', {
        get: function() {
          return this._c.size;
        },
      });
    }
  }
})(require('babel-runtime/core-js/set').default);

@ukasiu
Copy link
Author

ukasiu commented Apr 28, 2017

thanks, works like a charm.

@mortezaalizadeh
Copy link

I have the same problem here, everything works fine in iOS and Android when attached to ChromDevtool, but not in unattached or release mode on my phone. Could you please let me know where to apply the above fixes?

I looked at core-js source and latest version installed on my box is way older than what we currently have on the github repo. Looks like nothing has been released since a year ago. :( It is not an easy job to apply your changes. Only way is to replace the local installed core-js in node_modules.

@gusbicalho
Copy link

gusbicalho commented May 8, 2017 via email

@mortezaalizadeh
Copy link

Thanks heaps man, worked

lukewlms pushed a commit to lukewlms/relay that referenced this issue May 23, 2017
Relay just didn't work on Android for me.  My investigation here:
facebook#1797

Solution was posted here:
facebook#1704 (comment)

I think this is an invaluable warning to save other early adopters hours trying to dig into Relay Modern source and debug this issue.  Thanks.
@petersuwara
Copy link

petersuwara commented May 26, 2017

@gusbicalho, thanks. Your black magic fixed my Android QueryRenderer for React-Native. I wasn't getting the props through the results.

Could you please explain why/how this fixes the issue... It's frustrating that it doesn't make any sense whatsoever.

Thank you again.

@gusbicalho
Copy link

@petersuwara see zloirock/core-js#297 for an explanation of the bug. Apparently the polyfill used by relay is not compatible with the base implementation of Set on react-native android. I don't know why the implementation for ios is different.

What my snippet does is require the Set polyfill that relay uses, then monkey-patch it to add the size property, which was missing. The polyfill wraps the original Set and stores is as _c, so i can get the set size from there.

I don't know how long it will take to have a working version of this. core-js development doesn't seem very active :/ the mantainer apparently merged a fix, but hasn't released a new version to npm yet.

leebyron added a commit that referenced this issue Jun 7, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 7, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
leebyron added a commit that referenced this issue Jun 8, 2017
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
facebook-github-bot pushed a commit that referenced this issue Jun 8, 2017
Summary:
This removes babel's core-js polyfills from the distributed NPM builds. This aids in further reducing app bundle size when targeting modern browsers, and allows flexibility in how these polyfills are provided if necessary, which can help fix React Native specific issues, as illustrated in #1799 and #1704 and #1818.

The drawback is that polyfills for these things are now something that client developers will need to think about directly. Shipping Relay to older browsers before this diff should work fine, but after this diff will require global polyfills. As such, this diff may constitute at least a minor-breaking change.
Closes #1870

Differential Revision: D5208428

Pulled By: leebyron

fbshipit-source-id: 87d6602f1f29c6c15abbc0102958f41c3d00f8a5
@leebyron
Copy link
Contributor

leebyron commented Jun 8, 2017

Closing since the problematic Set polyfill will no longer be included in the next release.

@leebyron leebyron closed this as completed Jun 8, 2017
@danny-larsen
Copy link

danny-larsen commented Jul 11, 2018

I have this problem on a new React Native project. I am using the latest versions of react-relay.

Adding the script by @gusbicalho does not seem to work.

Any ideas?

EDIT:
For anyone still getting this error.
I rolled back react-realy version to an older one and now it works.

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

No branches or pull requests

6 participants