bigcache icon indicating copy to clipboard operation
bigcache copied to clipboard

Stop printing message when doing a context shutdown

Open rubenv opened this issue 2 years ago • 5 comments

Uses the configured logger instead.

rubenv avatar Sep 11 '23 11:09 rubenv

Good catch, thanks!

cristaloleg avatar Sep 11 '23 11:09 cristaloleg

Probably this was the reason :) https://github.com/allegro/bigcache/actions/runs/6145556141/job/16673759956?pr=374#step:5:25

cristaloleg avatar Sep 11 '23 11:09 cristaloleg

I honestly have no idea why it would cause that.

rubenv avatar Sep 11 '23 11:09 rubenv

AFAIR it's because during a test run os.Stdout is replaced with a test-specific writer to catch the full output. And because this we're logging in a goroutine we can log after a test end, which results in a panic due to Go test cleanup.

If you're curious to fix it than try to replace this context with context.WithCancel(...) https://github.com/allegro/bigcache/blob/157556c5afaeebd739cdbff4755e65f88a5d95af/examples_test.go#L63

And if you're not curious (which is fine too) I will take a look later today (leaving PR open for some time).

Thanks.

cristaloleg avatar Sep 11 '23 11:09 cristaloleg

@rubenv Ping

janisz avatar Nov 02 '23 18:11 janisz