Reduce blocking of event loop when parsing large ip lists - #1122
Reduce blocking of event loop when parsing large ip lists#1122timokoessler wants to merge 2 commits into
Conversation
Summary by Aikido
⚡ Enhancements
🔧 Refactors
|
| await this.serviceConfig.updateBlockedIPAddresses(blockedIPAddresses); | ||
| this.serviceConfig.updateBlockedUserAgents(blockedUserAgents); | ||
| this.serviceConfig.updateAllowedIPAddresses(allowedIPAddresses); | ||
| this.serviceConfig.updateMonitoredIPAddresses(monitoredIPAddresses); | ||
| await this.serviceConfig.updateAllowedIPAddresses(allowedIPAddresses); | ||
| await this.serviceConfig.updateMonitoredIPAddresses(monitoredIPAddresses); |
There was a problem hiding this comment.
🟡 Medium - Async IP list refreshes temporarily keep the old access policy active
The refresh path now awaits three independently asynchronous matcher builds and publishes each list separately. IPMatcher.createAsync() deliberately yields back to the event loop while parsing large lists, so requests handled during a refresh still consult the previous allowlist/blocklist snapshot and can observe a mix of old and new policy. An IP that has just been removed from allowedIPAddresses therefore remains able to access the service until the rebuild completes, and overlapping refreshes can also let a late older build overwrite newer policy.
Show fix
Build the blocked, allowed, and monitored IP matchers into a new immutable snapshot and swap that snapshot into ServiceConfig only once all of them are ready. Tie each async rebuild to a monotonically increasing generation or configUpdatedAt value so a late completion cannot overwrite a newer refresh.
Reply to ignore this finding.
More info
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
No description provided.