fix(server): dedupe remote collection requests - #535
Conversation
commit: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe server bundle now caches the in-flight promise for each remote collection. Concurrent calls share one fetch. Rejected fetches and JSON parsing failures clear the cache and allow retries. Falsy collection results are not retained. New tests load the generated server bundle and verify concurrent deduplication, successful caching, failure retries, and retries after falsy responses. Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Remote icon collections now share concurrent downloads while retaining caching and retry behavior after failed or falsy responses. The covered behavior is ready to merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
src/bundle-server.tsParsing error: Unexpected token { test/server-bundle.test.tsParsing error: Unexpected token { 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 |
🔗 Linked issue
Resolves #534.
📚 Description
Concurrent server API requests for different icons in one cold remote collection each started a full collection download.
createRemoteCollectionassigned its cache afterfetch(...).json()resolved, so overlapping callers all saw an empty cache.This stores the pending operation immediately, then replaces it with the resolved collection. A fetch or JSON parse rejection clears the cache so a later request can retry. Falsey JSON values retain the existing retry behavior.
The production Node repro holds origin responses until requests overlap. With 20 consumers of one 49,940-byte collection:
Copy/paste repro (published package, then pnpm patch):
The verifier also checks recovery after invalid JSON and after a
nullcollection result. It uses distinct icon API keys so Nitro's response cache does not hide collection-level requests.Validation:
The cache is process-local and applies to remote server bundles.