Open cfabio opened 5 years ago
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.
I think it has to do with this library because the moment I import it the UI stops working; stdout and stderr are empty.
I don’t know how to help you. If electron do not print errors, probably there is not errors.
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.
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.
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.
generate-function
used for runtime generate buffer to integer parsers. It gives maximal performance. Anyway, this related to generate-function
module. @bhspencer
@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().
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 https://github.com/electron-userland/electron-builder/issues/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.
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