-
Notifications
You must be signed in to change notification settings - Fork 18
lnc+util: assign WASM callbacks to a namespaced scope #79
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
Conversation
itsrachelfish
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why that's happening. Can you confirm that the callbacks for all four connections are all being called? It should be logged in the console. You can also check that the local/remote keys are set for all 4 nodes in localStorage. |
|
@jamaljsr after doing some further testing it looks like we might be hitting some kind of rate limiting / DOS protection in Firefox. You can see in this first screenshot (firefox) only three of the WASM binaries are loaded - However in Chrome it works fine with 4 simultaneous connections - |
Interesting. I was not aware of that limitation, but it's definitely something we need to consider when handling multiple WASM instances. I wonder how the other browsers (Safari, Edge, Brave) handle it. Also mobile browsers may have strict limitations as well. |
itsrachelfish
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this since my test script was able to connect 4 clients simultaneously in different namespaces using Chrome. Seems like we're hitting some other edge case in Firefox loading the WASM files. 🤔
kaloudis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK. Great job, Jamal!



This PR updates the LNC class to no longer use the JS
globalobject for the callbacks from the WASM client. The callbacks functions will now be nested under an object using thenamespaceas a name. So if the app usesnew LNC({ namespace: 'myapp' });, the callbacks will be created on theglobal.myappobject instead of previously being onglobal.This depends on lightninglabs/lightning-node-connect#72 which has been merged into the
masterbranch.Steps to test with the kitchen-sink demo:
make wasmto produce the WASM binarylnc-webrepolightning-node-connect/example/wasm-client.wasmintolnc-web/demos/kitchen-sink/public/kitchen-sink/src/App.jsto use the new WASM binary and your own pairing phrase and namespacelnc-webcode. Then start the appgetInfowindow.onLocalPrivCreateisundefinedand thattypeof window.myapp.onLocalPrivCreateisfunctionNote: This PR also fixes an issue in the
credentialStorewhere it was overwriting the data on every page reload in the kitchen-sink demo. This was due to the password being provided in the constructor.