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

Add an option for periodic flush #193

Open
segevfiner opened this issue Feb 22, 2024 · 7 comments
Open

Add an option for periodic flush #193

segevfiner opened this issue Feb 22, 2024 · 7 comments

Comments

@segevfiner
Copy link

When used for logging there could be cases of quiet periods where some log messages are buffered, but otherwise not yet flushed as they haven't filled the buffer yet. It would be helpful if sonic-boom would flush such messages after enough time passed without any new messages getting written so as you can still see what's the latest thing that has been logged in such cases without having to turn on sync mode.

@segevfiner
Copy link
Author

Actually... Why is anything getting buffered in the first place when I use this via pino-pretty without any minLength... Something is buffering messages sync or not...

@segevfiner
Copy link
Author

Probably due to this pinojs/pino#1801

@segevfiner
Copy link
Author

Anyhow I think that this is only relevant with minLength set, AKA actual buffering taking place, which it isn't by default as far as I can see. So I'm probably experiencing something starving the event loop.

@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@forgotPassword
Copy link

+1. Using set/clearInterval and calling .flush() seems to work for now.

@mcollina
Copy link
Member

mcollina commented Mar 31, 2024

I think that's easy enough and it does not required any special handling to prevent leaking. Would you like to send a PR to document it in the docs?

@forgotPassword
Copy link

Flush will throw an error if sb.destroyed, so you either have to try,catch this call or pass a do_nothing callback, which in turn sets and removes several drain events each time, seems wasteful for this case. As this library has several subtleties it would be great if someone who is more familiar with the code base added this functionality natively.

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

3 participants