lestrrat-go / httprc

Quasi Up-to-date HTTP In-memory Cache

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some URLs are lost in the queue and not refreshed

molszowy opened this issue · comments

Hi!

Thanks for the work on this module. Really appreciate it.

I think I found a bug when trying to use JWK auto-refresh which leverages this module.

When you register multiple URLs, each entry for respective URL should be enqueued in fetchLoop however some legitimate entries are lost and effectively some URLs are not refreshed at all.

slice is mutable so here the item is incorrectly inserted and the following code would help:

list = append(list[:i+1], list[i:]...)
list[i] = &rqentry{fireAt: fireAt, url: u}

Let me know what you think @lestrrat.

Oh, yeah, that looks like something that needs two steps instead of one.
Can you please create a PR that also contains a failing test ? Thanks!

I didn't have time to get to this earlier. Thanks for the quick fix!

@molszowy no problem, thanks for the report!