realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

Subscription not defined in react native - debug mode #1711

Closed cosinus84 closed 6 years ago

cosinus84 commented 6 years ago

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

skizzo commented 6 years ago

+1

ming436534 commented 6 years ago

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

cosinus84 commented 6 years ago

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

pedrozero-com commented 6 years ago

Same issue here. Downgrading from realm@2.3.0 to realm@2.2.15 solves this problem.

payucads commented 6 years ago

+1

liamjones commented 6 years ago

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

kaixinfu commented 6 years ago

+1

arshbot commented 6 years ago

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

saarnilauri commented 6 years ago

Having the same issue.

cosinus84 commented 6 years ago

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

V1sk commented 6 years ago

+1

jadelmir commented 6 years ago

I downgraded from 2.3.0 to 2.2.8 using npm: install realm@2.2.8 and after that run: react-native link it redownloaded the cocoa packages and it worked fine for me good luck 🥇

ameenmattar commented 6 years ago

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

V1sk commented 6 years ago

Downgrading realm@2.3.3 to realm@2.2.15 still has this issue

saarnilauri commented 6 years ago

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

uwajacques commented 6 years ago

@jadelmir Thanks, it works for me

jeprojects commented 6 years ago

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

donni106 commented 6 years ago

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

Dexwell commented 6 years ago

+1, please fix this critical bug

kneth commented 6 years ago

Please see #1744

arshbot commented 6 years ago

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

febeling commented 6 years ago

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

juliancorrea commented 6 years ago

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

kneth commented 6 years 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

fredimartins commented 6 years ago

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

kneth commented 6 years ago

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

Dexwell commented 6 years ago

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

jeprojects commented 6 years ago

@kneth Same problem as @Dexwell

artutra commented 6 years ago

@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

maxhalty commented 6 years ago

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!

kneth commented 6 years ago

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

HZSamir commented 6 years ago

I am still encountering this issue on 2.4.0

artutra commented 6 years ago

@Unforgiven-wanda Are you using react-native-queue package? It uses realm@2.0.12

HZSamir commented 6 years ago

@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

kneth commented 6 years ago

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

HZSamir commented 6 years ago

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

kneth commented 6 years ago

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

cosinus84 commented 6 years ago

I just tested and #1711 is fixed in 2.4.1