Closed zacharygriffee closed 11 months ago
Interesting! Do you have any test case we canxrun?
I'll work on one, asap.
My apologies, as the problem isn't particularly corestore related. The error occurs for me when there is any latency between the connection and the channel open. Here is what causes the error for me:
swarm1.on("connection", socket => {
socket.on("error", e => {
console.log("socket1 error", e);
});
console.log("Connection 1");
mux1 = new Protomux(socket);
channel1 = channel(mux1, hs => {
console.log("mux1 channel opened", hs);
});
// THIS latency caused the error
sleep(100).then(
() => {
channel1.open("from mux1");
}
);
core1.replicate(mux1);
corestore1.replicate(mux1);
});
function channel(mux, channelOpen) {
return mux.createChannel(
{
...debugProtocolKey,
onopen: channelOpen,
handshake: c.utf8
}
);
}
Thanks for your attention. I'm sure I can work around this.
I wanted to follow up here. I been battling this problem going on 3 days which I thought I could get around but I can't. I finally produced tests that nails down the issue but its simple. The problem occurs with the Hyperswarm DHT relay so I'm going to post a n issue at Hyperswarm DHT relay about the problem.
Possibly related: https://github.com/holepunchto/corestore/issues/45#issue-1556915539
I am using protomux extensively with numerous channels on a hyperswarm socket where individual hypercores are being replicated fine to all the other computers.
I decided to just replicate batches of cores with a namespacing of Corestores.
I am getting invalid open (on client) and rejection messages (on server) that close the socket of channels. If I comment out the corestore replication everything works just fine. The individual cores that I replicate in this manner replicate just fine as well. This occurs on all micro-services I have going that the corestore replication is being utilized (nodejs and browser).
I have tried these variations of replication pseudo-code:
corestore.replicate(mux); corestore.replicate(noiseSocket); corestore.replicate(isInitiator, mux); corestore.replicate(isInitiator, noiseSocket)