-
Notifications
You must be signed in to change notification settings - Fork 30
The abortable source hangs in the sink #120
Comments
Hello @filoozom Thanks for reaching out.
I am not entirely sure I understand you here. Once a libp2p connection exists, streams can be opened through that connection using a stream multiplexer. When a libp2p stream opens, A connection can have long lived streams, or short lived streams, which should also be partially closed (using closeRead + closeWrite). Once we support these features, users are able to individually close a given part of the async iterator flow. I Updated #115 to #121 as we are planning on getting that worked finished soon. But, I want to make sure we can move forward with a solution that can be used for all the use cases. Can you provide us a simple code snippet of how you are expecting to interact with this (from libp2p), as well as a test scenario with the issue? |
I created a simple test case here: https://github.com/filoozom/js-libp2p-mplex-pr-115. The issue might come from my With
and with
As far as I can tell, the dialer sends a message on stream 1, then creates a new stream with the same ID and closes it afterwards. The listener is not happy because a stream with that ID already exists. I'm assuming that this is because this line: Line 62 in c06dd96
send({ id, type: Types.NEW_STREAM, data: name }) a second time. This is why I wanted to implement a new version of this using a third AbortController .
Sorry if I'm off base. I also just noticed that the listener sends |
Thanks @filoozom , will look into this today and get back to you |
This is how I got it to work for my needs: beejeez/js-libp2p-mplex@3db21df (not sure if it's entirely spec compliant) |
You are completely right. I can see that the problem of the #121 and previous PR. They only work correctly if the Looking at your proposed solution I think we only need to take care of an extra thing, which is the thing that currently works. This means, we should probably keep state on wether sink was previously called or not. So, if sink was not called, we would do What do you think? This probably means the ABortController current implementation would work? Edit: if so, probably the best approach would be to create a simple MuxedStream class that keeps the state of on going sink or not. Would you like to create a new PR with the changes of #121 and adding the abort controller like this? It would be good to also have a follow up version of this: libp2p/js-libp2p-interfaces#90 with a test that writes and then closesWrite |
Sounds good, do you want me to open a PR, or do you want to edit #121? The issue I'm having with writeCloseController.abort()
pipe([], sink) could work, but then we'd need a reference to the created sink, or something like a I don't know how this should be fixed. Apparently the |
Open a new PR, you might not have permissions to edit mine.
It should be waiting for the next occurrence. We should be able to just abort, but you can create the PR, even if the test fails and I can help you debug it |
resolved via #170 |
Hi,
I need to be able to close a write stream independently of the read one for a project that communicates with
libp2p
nodes written in Golang. I tried out #115, but I don't think that it works, as it seems like it's just creating a new stream and closing that one instead of the current one.I thus wanted to replace the
closeWrite
function by a thirdAbortController
, so that I could just skip the generator'scatch
and send theTypes.CLOSE
message.However, while doing this I noticed that I never reach the
catch
withAbortErrors
, because it hangs on the following line inabortable-iterator
: https://github.com/alanshaw/abortable-iterator/blob/master/index.js#L60. So neitherabortController
norresetController
controller works for me, and the third one I wanted to add doesn't either.I'm not familiar with async generators enough to know if there's a simple solution to this issue, I just know that commenting out the https://github.com/alanshaw/abortable-iterator/blob/master/index.js#L60 line makes it work. Would you have any suggestions regarding this issue?
The text was updated successfully, but these errors were encountered: