launch.json "target": "iPad 2"
3.debug iso
4.display error
[vscode-react-native] Debugging session started successfully.
Missing Realm constructor - please ensure RealmReact framework is included!
Module AppRegistry is not a registered callable module.
Unhandled JS Exception: Missing Realm constructor - please ensure RealmReact framework is included!
Unhandled JS Exception: Module AppRegistry is not a registered callable module.
run not debug
React Native version: 0.22.2
Output of the Debug Console (View -> Toogle Debug Console):
[vscode-react-native] Debugging session started successfully.
Skipping bundling for Simulator platform
=== BUILD TARGET houseTests OF PROJECT house WITH CONFIGURATION Debug ===
Check dependencies
* BUILD SUCCEEDED *
Installing build/Build/Products/Debug-iphonesimulator/house.app
Launching org.reactjs.native.example.house
org.reactjs.native.example.house: 9769
[vscode-react-native] Finished executing: react-native run-ios --simulator iPad 2
[vscode-react-native] Established a connection with the Proxy (Packager) to the React Native application
[vscode-react-native] Debugging session started successfully.
Missing Realm constructor - please ensure RealmReact framework is included!
Module AppRegistry is not a registered callable module.
Unhandled JS Exception: Missing Realm constructor - please ensure RealmReact framework is included!
Unhandled JS Exception: Module AppRegistry is not a registered callable module.
Output of the React-Native output channel (View -> Toogle Output -> Select React-Native in ListBox):
[Warning] Debugging is not supported if the React Native Packager is not started within VS Code. If debugging fails, please kill other active React Native packager processes and retry.
This looks like it might be a configuration issue with your project. I am not familiar with realm, but did you follow instructions like https://realm.io/docs/react-native/latest/#getting-started ? You may be missing the native code for Realm if I understand the error correctly.
project run ok in react-native run-iso
this error only show debug iso
What happens if you manually react-native run-ios and then you enable debugging in chrome? Does that work correctly, or does it break in a similar way?
You may need to close the project in VS code to make sure that we remove all of our debugging hooks and that it attempts to launch chrome.
manually react-native run-ios and then you enable debugging in chrome ,no error ,is ok
only vscode debug ,debug iso
Ok, we will have to look into this further. Thanks for reporting this.
test more times ,use debug mode,add breakpoint, run debug ,sometimes show error;
when error ,reboot similator ,delete app,debug again
if run ok ,debug to be invalid,breakpoint not break;
This trigger this error condition:
1、use realm
2、vscode debug , Successfully set up iso simulator environment debugging in Chrome
use
react-native run-ios
debug in chrome
is ok ,no error
I've looked into this a bit now, and it looks like Realm is not compatible with our extension, since they try to detect whether the app is being debugged, and the way we run things does not match what they expect. We'll have to work out how best to address this.
@MSLaguana Please let us know how we can fix this in Realm. We'd be happy to make that fix, or you can send us a PR if you'd like.
@appden: I can certainly point you to the incompatibility: If you look at https://github.com/realm/realm-js/blob/d62f78050ee61c67c0c60cdc83908b6c2a2eae81/lib/index.js#L27 then you'll see you check first for native support, then you check for a browser environment, and if both checks fail then you bail out.
When we debug react-native projects, we follow the same concept as debugging in chrome, except we use nodejs rather than a browser environment, which means that there won't be a navigator element, but since we are running on the host machine and not the device itself it also won't have the native-modified javascript environment. A better "am I running in a debug environment" check may be to look for __DEV__, which the packager sets to true in debug mode I believe. I'm not sure if that's always the case though.
I haven't looked deeper to see if your browser support also works in a nodejs environment. If it doesn't, then more work would be needed to support your functionality in a nodejs environment.
I just tried this out and this change isn't quite enough to get things working. Realm needs to be able to make synchronous http requests in order for the rpc layer to work in debug mode. We had to jump through a few hoops to make this work with react-native/chrome and we may need to do the same to get things working with this setup.
any new about this? I really want to move to VS already
@MSLaguana I think I figured out what we need to get this working. I tried using sync-request, but I need to require() it with the native Node require() function that VS Code exposes into the sandbox here. Unfortunately, the React Native code overrides that here. If you could also expose the same require() function as nativeRequire() then we could use that to gain access to the sync-request module and things should work from there. :smile:
I've set up a PR that should provide this functionality. If you could try it out and see if it meets your needs, that'd be appreciated.
I've merged the PR now, but I'll leave this issue open until the next version of the extension is published, and Realm has a fix on their end.
anything new about this bug?
We have just published a release of the extension which exposes the __debug__.require function, but Realm still needs to make use of that before it will work correctly, so I'll keep the issue open for now.
Is there any progress?
That's a question for @appden
@appden Pardon my naive question - Is there a reason you guys are doing a special case for VSCode and browser platforms ? Other native plugins (like camera) seem to work just fine. Is there more documentation about this that I can read up on ?
This will be resolved by PR realm/realm-js#512. Thanks again for your help @MSLaguana!
@axemclion Debug mode for Realm requires we make synchronous HTTP requests to the application from wherever the JS is being debugged (normally Chrome, but Node in the case of VS Code). That is why we sprinkle in some special sauce to make this work. :smile:
@appden Thanks. Btw, do you work at Realm ? I was planning to write something like a "Storage Explorer" for Realm with VSCode, and had some questions about collaboration.
@axemclion I'm have been working on Realm for React Native, but I'm taking some time away for the next couple months, so I recommend you talk to @alazier, who is leading the project. Good luck!
Closing since realm has updated and it works now.
Hi, I'm using the latest realm (v0.14.3) and visual studio (Version 1.5.2 (1.5.2)) and I still get the error on iOS simulator during debug: 'Missing Realm constructor - please ensure RealmReact framework is included!'
"dependencies": {
"react": "^15.3.0",
"react-native": "^0.32.0",
"realm": "^0.14.3"
}
cc: @MSLaguana @appden
Looks like Realm still has the original check that caused this issue.
They have made use of the __debug__.require at https://github.com/realm/realm-js/blob/master/lib/browser/rpc.js but the file making the check https://github.com/realm/realm-js/blob/master/lib/index.js is still checking for a window variable which doesn't exist in node.
@appden, I had a look at https://github.com/realm/realm-js/commit/717d6781a185c214154ec422f836ce1a79363576 which claims to add support for vscode debugging, but I'm not sure how the window check is intended to work. We haven't changed anything relevant here to my knowledge.
@MSLaguana You're absolutely right about window, but at the time I was successfully able to debug with VS Code, but that may have been relying on something else to inject the window alias. I'm not actively working on the project right now, but I'll cc those who are here: @alazier @fealebenpae
It would be good to get an idea of when this will be fixed. I was planning to use Realm in a project but this is making it impossible.
@alazier @fealebenpae
For a temporary workaround, you could try global.window={} at the start of your index.<platform>.js file. I believe that will convince realm to operate correctly.
Unfortunately that doesn't work. But I like your thinking.
@alazier @fealebenpae - Any updates on this one?
We are working on a fix for this which should hopefully go into the next release.
Thanks @alazier . Is there an ETA?
Hi @alazier , Is this supposed to be fixed now? I'm unable to debug on VSCode with realm on the latest version.
@alazier any updates? Currently seeing this issue as of today
Most helpful comment
Ok, we will have to look into this further. Thanks for reporting this.