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

Compatibility with REACT #22

Open
cfabio opened this issue Jun 5, 2019 · 9 comments
Open

Compatibility with REACT #22

cfabio opened this issue Jun 5, 2019 · 9 comments

Comments

@cfabio
Copy link

cfabio commented Jun 5, 2019

Hi, I am trying to use this library in an Electron + React project I am developing.
For some reason everything works nicely as long as I run the application in debug mode, if I try to run the production ready compiled binary of the app I get and empty blank window.
Do you have any clue on why this might be happening? I am at a loss here, can't really find a solution.
Thanks

@reklatsmasters
Copy link
Member

There is no need some extra compatibility. Why do you think your problem related to stun? Try to check stderr, console, wtv. I'm not an extrasensory.

@cfabio
Copy link
Author

cfabio commented Jun 5, 2019

I think it has to do with this library because the moment I import it the UI stops working; stdout and stderr are empty.

@reklatsmasters
Copy link
Member

I don’t know how to help you. If electron do not print errors, probably there is not errors.

@cfabio
Copy link
Author

cfabio commented Jun 6, 2019

I managed to debug the production code using some third party library.
The issue seems to be related to how "stun" and related libraries import each other.
See attached screenshot.
screenshot_2019-06-06_at_11 10 43

@reklatsmasters
Copy link
Member

reklatsmasters commented Jun 6, 2019

Your module loader should follow nodejs module loader rules. NodeJS trying to add node_modules folder to each one starting from main file folder. See nodejs docs. I don’t known how to work Electron’s module resolver.

@bhspencer
Copy link

I am also running this stun library in an electron app and believe I have a related issue.

I am able to run this stun library if I am in the main process but not if I am in a render process. The render process is using a content security policy that prevents the execution of the transitive dependency called generate-function:

└─┬ stun@2.1.0
├─┬ binary-data@0.6.0
│ ├─┬ generate-function@2.3.1

In particular generate-function uses eval() which is prohibited by the security policy for reasonable reasons.

This is unfortunate as in order to get my public ip in the render process I have to set up a bunch of inter process communication to the main process. I would prefer to not have to do that.

@reklatsmasters
Copy link
Member

generate-function used for runtime generate buffer to integer parsers. It gives maximal performance. Anyway, this related to generate-function module. @bhspencer

@bhspencer
Copy link

@reklatsmasters I could imagine that generate-function provides maximal convenience. STUN packets are not particularly complicated, the maximally preferment way of decoding STUN messages from a buffer would be to write an explicit decoder rather than use eval().

@ilittle-cnri
Copy link

FYI, I ran into the issue describe by @cfabio as well. I believe the issue is a bug in electron-builder that's causing it to strip out nested node_modules folders, which breaks this package. See electron-userland/electron-builder#3185

If I build with electron-forge, it leaves the nested node_modules alone and the stun package works just fine in the production Electron+React app.

Anyway, upshot is, @reklatsmasters I think you can close this issue. It's not a node-stun bug, it's an electron-builder bug.

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

4 participants