chr15m / bugout

Back end web app services over WebRTC.
https://chr15m.github.io/bugout
MIT License
603 stars 59 forks source link

Peer Rpc call default values to args #63

Closed Kos-M closed 1 year ago

Kos-M commented 1 year ago

Hello , If you dont specify any arg in rpc call like this:

b.rpc(address, callname, args, callback);

you end up with error on remote peer (destination of rpc call)

Cannot read properties of undefined (reading 'toString')

I think it should have a default empty object if user not specify args..

chr15m commented 1 year ago

@Kos-M good point, thanks for catching this. I think the best thing to do is check for args == undefined || args == null in the RPC receiving code and then don't run toString if it is undefined or null.

If you or somebody else submits a PR with a) a fix b) updated tests to catch this case, I'll merge it. Thanks!

Kos-M commented 1 year ago

Sure , you welcome . Maybe ill fix it this weekend. Im using this project in 2 different side projects im currenlty developing , so expect more issues from me if find anything else , to imrpove it more :)

Noticed all tests are in one single file , would it be better to seperate tests by test entity to each own file ( maybe in a folder) ? For example rpc.test.js , torrent.test.js

chr15m commented 1 year ago

I'm not sure about separating things out. In general I'd prefer a PR that does one small thing at a time so it's easy to check.

Kos-M commented 1 year ago

No , i didnt mean to modify /seperate tests now , maybe in feature some time..