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

Block on full channel? #1

Open
rmccue opened this issue Jan 25, 2024 · 0 comments
Open

Block on full channel? #1

rmccue opened this issue Jan 25, 2024 · 0 comments

Comments

@rmccue
Copy link
Owner

rmccue commented Jan 25, 2024

Currently, we're using Tokio's channels for the .await support in AsyncLogger::run. This means we need to use Sender::try_send since Tokio's Sender::send is async, and io::Write needs to be synchronous.

However, this also means if the buffer is full, we can't write that data out, and we don't block on it. Instead, we return a io::ErrorKind::OutOfMemory.

Unfortunately, asciinema doesn't seem to do anything with this (like apply backpressure to the stream), so we silently drop logs instead. This is unfortunate, particularly if you're using the logging functionality for security-oriented purposes (like an audit log).

This might be fixable by switching to std::sync::mpsc::sync_channel instead, whose Sender::send is blocking (or std::sync::mpsc::channel which has an "infinite buffer", no idea how that works) - however, this means the Receiver side can't use timeout().await and needs to use recv_timeout instead.

Not sure on the implications or if this will even work - or if blocking is even desirable! tbd.

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

No branches or pull requests

1 participant