You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What programming language are you using (C/C++/Go/Rust)?
N/A (but usually Javascript/Typescript)
What did you expect to see and what you saw instead?
When investigating how/if socket apps can disconnect from the p2p-network (looks like the answer might be (await network({})).peer.close() as opposed to (await network({})).disconnect()) I spotted what appears to be a network optimization that is never executed when invoking subcluster.emit().
On the surface, the "fix" might be as simple as checking for sub.peers.size rather than sub.peers.values().length (because Map iterators have no such property by default).
Looking deeper, that change would exercise code which was likely never executing prior, and may have the following side effects compared to the local Peer.publish() fallback (which was presumably always safe):
no "#packet" events are emitted to the socket/bus as otherwise would occur during a Peer.publish()
the packets ultimately handed to _peer.mcast() will have usr4 and usr3 set to the peerId of the local peer and the first remote peer respectively -- and will be of type PacketStream rather than PacketPublish
it's not entirely obvious to me that RemotePeer.write() was getting exercised anywhere, and though I doubt it's the case, it might not work as expected -- one place it's potentially getting exercised is below, which seems to use a possibly stale reference to the closure's peer.write instead of ee._peer.write
If any of these seem like genuine issues, I'd be happy to submit a PR, but I'd want some guidance on how to appropriately test proposed changes. Do you have a solution for mocking a network of peers?
The text was updated successfully, but these errors were encountered:
What OS are you using (
uname -a
, or Windows version)?Darwin Kernel Version 22.4.0: Mon Mar 6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112 arm64
Mac OS Ventura 13.3.1 (22E261)
What version Socket Runtime are you using?
Reading an unreleased commit after v0.5.4 -- https://github.com/socketsupply/socket/tree/0c235fb4fa97f552c759551c9daab815a96eeaa9
What programming language are you using (C/C++/Go/Rust)?
N/A (but usually Javascript/Typescript)
What did you expect to see and what you saw instead?
When investigating how/if socket apps can disconnect from the p2p-network (looks like the answer might be
(await network({})).peer.close()
as opposed to(await network({})).disconnect()
) I spotted what appears to be a network optimization that is never executed when invokingsubcluster.emit()
.socket/api/stream-relay/sugar.js
Line 256 in 0c235fb
On the surface, the "fix" might be as simple as checking for
sub.peers.size
rather thansub.peers.values().length
(becauseMap
iterators have no such property by default).Looking deeper, that change would exercise code which was likely never executing prior, and may have the following side effects compared to the local
Peer.publish()
fallback (which was presumably always safe):"#packet"
events are emitted to thesocket
/bus
as otherwise would occur during aPeer.publish()
socket/api/stream-relay/index.js
Lines 974 to 984 in 0c235fb
socket/api/stream-relay/sugar.js
Lines 264 to 272 in 0c235fb
socket/api/stream-relay/sugar.js
Lines 60 to 63 in 0c235fb
_peer.mcast()
will haveusr4
andusr3
set to thepeerId
of the local peer and the first remote peer respectively -- and will be of typePacketStream
rather thanPacketPublish
socket/api/stream-relay/sugar.js
Lines 260 to 261 in 0c235fb
socket/api/stream-relay/index.js
Lines 200 to 204 in 0c235fb
socket/api/stream-relay/index.js
Line 972 in 0c235fb
RemotePeer.write()
was getting exercised anywhere, and though I doubt it's the case, it might not work as expected -- one place it's potentially getting exercised is below, which seems to use a possibly stale reference to the closure'speer.write
instead ofee._peer.write
socket/api/stream-relay/sugar.js
Lines 317 to 325 in 0c235fb
If any of these seem like genuine issues, I'd be happy to submit a PR, but I'd want some guidance on how to appropriately test proposed changes. Do you have a solution for mocking a network of peers?
The text was updated successfully, but these errors were encountered: