ADE-61: Avoid building APNs bridge service on every getAdeActionDomainServices call#437
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 26 minutes and 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
|
@copilot review but do not make fixes |
f6fe07e to
afb25f1
Compare
|
@copilot review but do not make fixes |
afb25f1 to
95ce639
Compare
|
@copilot review but do not make fixes |
95ce639 to
a970aa2
Compare
|
@copilot review but do not make fixes |
a970aa2 to
c01f36f
Compare
|
@copilot review but do not make fixes |
Fixes ADE-61
Summary
Describe the change.
What Changed
Key files and behaviors.
Validation
How you tested.
Risks
Anything to watch.
Linked Linear issues
Greptile Summary
This PR avoids rebuilding the APNs bridge service on every
getAdeActionDomainServicescall by introducing aWeakMap-based cache keyed byAdeRuntimeand convertingnotifications_apnsfrom an eagerly-computed value to a lazy getter.WeakMap<AdeRuntime, CachedApnsBridgeDomainService>stores the bridge instance and the three dependency references (projectConfigService,apnsService,apnsKeyStore) used to detect staleness; the cache is invalidated when any of those references change.notifications_apnsis now a getter in the returned object so APNs dependencies are not read at all when an unrelated domain is accessed, and three new tests cover the lazy initialisation, cache reuse, and cache invalidation paths.Confidence Score: 5/5
Safe to merge — the change is a targeted performance optimisation with no behavioural regressions.
The WeakMap cache is keyed on the runtime object and invalidated whenever any of the three tracked dependency references change. The lazy getter correctly defers APNs dependency access, and the toService wrapper in the getter handles any falsy return from createApnsBridgeService. The getDeviceRegistryService closure captures runtime directly so it stays current even when syncService is replaced without a cache miss. All three critical paths (lazy skip, cache hit, cache invalidation) are covered by the new tests.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["getAdeActionDomainServices(runtime)"] --> B["Return object with getter\nnotifications_apns"] B --> C{"Caller accesses\nnotifications_apns?"} C -- No --> D["APNs deps never read\n(lazy evaluation)"] C -- Yes --> E["getApnsBridgeDomainService(runtime)"] E --> F{"WeakMap cache hit?\n(runtime key exists)"} F -- No --> G["createApnsBridgeService(...)"] G --> H["Store in WeakMap\n{projectConfigService, apnsService,\napnsKeyStore, service}"] H --> I["Return service"] F -- Yes --> J{"Dependency refs equal?\n(projectConfigService ===\napnsService === apnsKeyStore)"} J -- Yes --> K["Return cached service"] J -- No --> G I --> L["toService(service)\nOpaqueService | null"] K --> LReviews (5): Last reviewed commit: "fix: memoize APNs ADE action bridge" | Re-trigger Greptile