lestrrat-go / httprc

Quasi Up-to-date HTTP In-memory Cache
MIT License
17 stars 5 forks source link

Some URLs are lost in the queue and not refreshed #6

Closed molszowy closed 2 years ago

molszowy commented 2 years ago

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.

lestrrat commented 2 years ago

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!

molszowy commented 2 years ago

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

lestrrat commented 2 years ago

@molszowy no problem, thanks for the report!