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

Do not swallow the panic when the eviction listener is panicked #391

Open
tatsuya6502 opened this issue Jan 28, 2024 · 0 comments
Open

Do not swallow the panic when the eviction listener is panicked #391

tatsuya6502 opened this issue Jan 28, 2024 · 0 comments

Comments

@tatsuya6502
Copy link
Member

As of moka@v0.12.4, it swallows the panic when the eviction listener is panicked. This behavior is documented but can be easily overlooked.

https://docs.rs/moka/0.12.4/moka/sync/struct.Cache.html#you-should-avoid-eviction-listener-to-panic

It is very important to make an eviction listener closure not to panic. Otherwise, the cache will stop calling the listener after a panic. This is an intended behavior because the cache cannot know whether it is memory safe or not to call the panicked listener again.

When a listener panics, the cache will swallow the panic and disable the listener. If you want to know when a listener panics and the reason of the panic, you can enable an optional logging feature of Moka and check error-level logs.

Change it to re-throw the panic after catching it and disabling the eviction listener.

@tatsuya6502 tatsuya6502 changed the title Do not swarrow the panic when the eviction listener is panicked Do not swallow the panic when the eviction listener is panicked Jan 28, 2024
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