-
Notifications
You must be signed in to change notification settings - Fork 42
fix: lifecycle for dns resolver initialization #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
deps: delete @eggjs/tegg
📝 WalkthroughWalkthroughReorganizes plugin/dns-cache lifecycle by moving DNS resolver attachment into configDidLoad and separating HTTP client lookup setup; removes the Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as Application
participant Config as Lifecycle (configWillLoad)
participant Did as Lifecycle (configDidLoad)
participant Http as HTTPClient
participant DNS as DNSResolver
rect rgba(200,230,255,0.2)
Note over Config,App: configWillLoad phase
Config->>App: initialize dnsResolver instance
Config->>Http: set httpclient.lookup = dnsResolver.lookup
end
rect rgba(220,255,200,0.2)
Note over Did,App: configDidLoad phase (moved)
Did->>App: attach dnsResolver to app (app.dnsResolver = dnsResolver)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
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 |
Summary of ChangesHello @Dipper30, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refines the lifecycle management of the DNS resolver within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly moves the DNS resolver initialization to the configWillLoad lifecycle hook, which is the appropriate place for modifying configuration. It also includes some cleanup by removing an unnecessary dependency and test plugins.
I've found one logical issue in plugin/dns-cache/app.ts where the DNS cache gets enabled with default settings even when its configuration is missing, which contradicts the warning message logged in that case. I've left a comment with a suggestion to fix this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
plugin/dns-cache/app.ts (1)
40-43: Consider removing unnecessary async keyword.The
configDidLoadmethod contains only a synchronous assignment and doesn't useawaitor return a Promise.🔎 Proposed refactor
- async configDidLoad() { + configDidLoad() { // Add dnsResolver to app this.app.dnsResolver = this.dnsResolver; }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
plugin/dns-cache/app.tsplugin/dns-cache/package.jsonplugin/dns-cache/test/fixtures/apps/dns_cache_lookup/config/plugin.jsplugin/dns-cache/test/fixtures/apps/dns_cache_lookup_http_next/config/plugin.jsplugin/dns-cache/test/fixtures/apps/dns_cache_resolve/config/plugin.js
💤 Files with no reviewable changes (3)
- plugin/dns-cache/test/fixtures/apps/dns_cache_lookup/config/plugin.js
- plugin/dns-cache/package.json
- plugin/dns-cache/test/fixtures/apps/dns_cache_resolve/config/plugin.js
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Dipper30
Repo: eggjs/tegg PR: 385
File: plugin/dns-cache/lib/DnsResolver.ts:6-6
Timestamp: 2025-12-25T08:31:56.726Z
Learning: The eggjs/tegg-dns-cache plugin in plugin/dns-cache intentionally supports only IPv4 addresses, not IPv6. The IP_REGEX in plugin/dns-cache/lib/DnsResolver.ts is deliberately IPv4-only by design.
Learnt from: Dipper30
Repo: eggjs/tegg PR: 385
File: plugin/dns-cache/lib/DnsResolver.ts:327-332
Timestamp: 2025-12-25T08:31:42.366Z
Learning: In the plugin/dns-cache DNS resolver implementation, nameserver TTL settings should be respected exactly as returned, even when zero, rather than enforcing a minimum TTL floor.
📚 Learning: 2025-12-25T08:31:37.423Z
Learnt from: Dipper30
Repo: eggjs/tegg PR: 385
File: plugin/dns-cache/lib/DnsResolver.ts:327-332
Timestamp: 2025-12-25T08:31:37.423Z
Learning: Ensure DNS TTL values returned by the DNS resolver in plugin/dns-cache are used verbatim, including 0, and do not apply any minimum TTL floor. During reviews, verify that the resolver does not override zero TTLs with a default/minimum value and that unit tests cover scenarios with TTL=0 as well as other TTLs.
Applied to files:
plugin/dns-cache/app.ts
📚 Learning: 2025-12-25T08:31:56.726Z
Learnt from: Dipper30
Repo: eggjs/tegg PR: 385
File: plugin/dns-cache/lib/DnsResolver.ts:6-6
Timestamp: 2025-12-25T08:31:56.726Z
Learning: The eggjs/tegg-dns-cache plugin in plugin/dns-cache intentionally supports only IPv4 addresses, not IPv6. The IP_REGEX in plugin/dns-cache/lib/DnsResolver.ts is deliberately IPv4-only by design.
Applied to files:
plugin/dns-cache/test/fixtures/apps/dns_cache_lookup_http_next/config/plugin.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Runner-macos (18)
- GitHub Check: Runner-ubuntu (20)
- GitHub Check: Runner-macos (16)
- GitHub Check: Runner-ubuntu (18)
- GitHub Check: Runner-ubuntu (16)
- GitHub Check: Runner-macos (20)
🔇 Additional comments (2)
plugin/dns-cache/app.ts (1)
12-38: LGTM! DNS resolver initialization correctly moved to configWillLoad.The lifecycle change is appropriate. Setting
httpclient.lookupinconfigWillLoadensures the DNS-cached lookup function is available when other plugins load their configurations.plugin/dns-cache/test/fixtures/apps/dns_cache_lookup_http_next/config/plugin.js (1)
16-19: LGTM! Test fixture path configuration is correct.The path correctly points to the
plugin/dns-cache/directory (6 levels up from the config directory), which aligns with the PR's test configuration adjustments.
4f71970 to
d8f7f97
Compare
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.