Skip to content
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

fix: fix possible non-termination in ingest_drop(). #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zicklag
Copy link

@zicklag zicklag commented Jan 1, 2025

Fixes an issue where ingest_drop() may not terminate.

I ran into this issue while adding a way to import drops in earthstar. I'm honestly not sure why the same issue isn't run into in the willow test cases, but I do have a failing test case in a PR to the Earthstar repo.

The issue is that we are pushing chunks into the FIFO and then later here, we are triggering a for await loop that will never end because the FIFO has no concept of an EOF or terminating message.

Then a little bit further down the code we are awaiting on the promise running that endless loop, so that we never finish.

This gets around the issue by wrapping the FIFO in a generator that will properly exit when we push an undefined to it. That way we can indicate the end of the stream.

Copy link
Contributor

@sgwilym sgwilym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that there were no failing test cases here for so long! As you're right, this FIFO should never end.

Would you be so kind as to make one modification? This kind of stopping pattern is used elsewhere in the codebase, but uses a symbol instead of undefined (e.g.

fifo: FIFO<Uint8Array | typeof CANCELLATION>;
). This makes it a little clearer what's happening.

Thank you!

@zicklag
Copy link
Author

zicklag commented Jan 2, 2025

Ah, great idea I'll do that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants