Realm-js: Subscription not defined in react native - debug mode

Created on 13 Mar 2018  路  38Comments  路  Source: realm/realm-js

Goals

Debugging react native application using realm 2.3.0. The bug is generating when importing realm.
All works fine in non-debug mode.

In 2.2.15 debug works ok.

simulator screen shot - iphone 6 - 2018-03-14 at 00 33 53

exports.default = Realm;
util.createMethods(Realm.prototype, _constants.objectTypes.REALM, ['addListener', 'removeListener', 'removeAllListeners', 'close', '_waitForDownload', '_objectForObjectId']);
util.createMethods(Realm.prototype, _constants.objectTypes.REALM, ['delete', 'deleteModel', 'deleteAll', 'write', 'compact', 'beginTransaction', 'commitTransaction', 'cancelTransaction'], true);
var Sync = {
User: _user2.default,
Session: _session2.default,
Subscription: Subscription
};
index.bundle?platform=ios&dev=true&minify=false:13121 Subscription is not defined

Actual Results


Steps to Reproduce

Code Sample

Version of Realm and Tooling

  • Realm JS SDK Version: 2.3.0
  • Node or React Native: 0.54.2
  • Client OS & Version: ios simulator
  • Which debugger for React Native: React native debugger
O-Community T-Bug

Most helpful comment

I downgraded from 2.3.0 to 2.2.8
using npm:
install [email protected]
and after that
run: react-native link
it redownloaded the cocoa packages and it worked fine for me
good luck 馃

All 38 comments

+1

I solved this problem by uninstalling the app from the simulator and build it again

Edited: Sorry it turns out that this method is not working for me as well...

Didnt worked for me, I even reset the simulator, reinstall modules, link aigan, etc. All worked fine with no debug mode. In debug mode the error appears again and if I comment import realm then debug mode works. For the moment I use 2.2.15 if i upgrade to 2.3.0 I will get the same error.

Just 1 min ago updated back to 2.3.0, uninstall the application from simulator, started again the builder etc, => Subscription is not defined

Same issue here. Downgrading from [email protected] to [email protected] solves this problem.

+1

Looks like it might be failing because #1583 changed browser/index.js to add Subscription to the Sync const but there's no import for Subscription? (link)

At least, that seems to be where it's falling over in the debugger

+1

Updating to 2.3.3 and deleting the app from simulator and rebuilding worked for me

Update: It does not work.. it just seems to silence the issue but communicating with realm results in the app freezing

Having the same issue.

2.3.3 still not fixed, same issues.
I really don't understand how everyone(besides us here) using 2.3.3 can debug their realm application. How does the realm team debug their application in react native with 2.3.3

+1

I downgraded from 2.3.0 to 2.2.8
using npm:
install [email protected]
and after that
run: react-native link
it redownloaded the cocoa packages and it worked fine for me
good luck 馃

Thank you @jadelmir , i followed your steps and it worked 馃憤

Downgrading [email protected] to [email protected] still has this issue

@V1sk I had the same issue. In my case, one of my apps dependencies had a child dependency to the realm js. Check your child dependencies.

@jadelmir Thanks, it works for me

Same here, any Realm 2.3.+ produces this error. 2.2.18 works fine.

Same here, Realm 2.3.3 produces this error. 2.2.18 works fine.

+1, please fix this critical bug

Please see #1744

Installed 2.3.3, still getting the Subscription is not defined error. Not getting it with 2.2.18

So now that #1744 is in, and while we await the upcoming release, the fix could be confirmed with a package build from master. I checked but didn't see instructions that I understand.

Anyone know how to build the package? (Just specifying realm/realm-js#master as dep isn't working.)

Same here. I've created a new project now and bug in 2.3.4 persists.
@kneth , the @artutra's commit doesn't released, right?
The last change in the last tag (2.3.4) was 2 months ago...

No, it hasn't been released.

And 2.3.4 was released last week: https://github.com/realm/realm-js/releases/tag/v2.3.4

Same here, 2.3.4 shows this error.
Downgraded to 2.2.18 and run android again works for me.

I have release 2.3.5, please report back if it doesn't work.

@kneth I get the error "Cannot redefine property: logout"

@kneth Same problem as @Dexwell

@Dexwell @jeprojects I mentioned this error in #1744 comment section, but I did not get answers about it.
I was able to resolve by changing 'logout' to '_logout' here:
https://github.com/realm/realm-js/blob/c3a83f1866542a148a52495a8e7f014c57c33c66/lib/browser/user.js#L45
Apparently this function is called here:
https://github.com/realm/realm-js/blob/c3a83f1866542a148a52495a8e7f014c57c33c66/lib/user-methods.js#L387

Hi guys! We are having the same problem over here...please let us know when you think a new release with this issue fixed will be published. thanks!

I have unpublished 2.3.5 and released it as 2.4.0 (and sneaked the logout fix in).

I am still encountering this issue on 2.4.0

@Unforgiven-wanda Are you using react-native-queue package? It uses [email protected]

@artutra No. I believe none of my libs have realm as a dependency.
FYI running on Ubuntu 17.10, Node 10, on emulator running Android 7.0

@Unforgiven-wanda Maybe checking node_modules manually is worth doing.

@kneth Deleting node_modules, cleaning the build files and reinstalling everything seems to have fixed it for me, although I have no idea why; the same procedure didn't take a few days ago.
All in all, Realm is still wildly unstable (when it comes to debugging) on RN. I swear I start praying to every divinity whenever I fiddle with it.

@Unforgiven-wanda RN debugging is our weakest point, please read https://github.com/realm/realm-js/issues/491#issuecomment-350718316

I just tested and #1711 is fixed in 2.4.1

Was this page helpful?
0 / 5 - 0 ratings