Skip to content

Conversation

@Dipper30
Copy link
Contributor

@Dipper30 Dipper30 commented Jan 6, 2026

  1. Move dnsResolver initialization from configDidLoad() to configWillLoad()
  2. Remove unnecessary unittest plugins

Summary by CodeRabbit

  • Refactor

    • Separated DNS cache plugin initialization into distinct lifecycle phases for clearer setup sequencing.
  • Chores

    • Removed dependency on eggjs/tegg package.
    • Updated test fixture configurations to align with the revised DNS cache plugin lifecycle and setup.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

📝 Walkthrough

Walkthrough

Reorganizes plugin/dns-cache lifecycle by moving DNS resolver attachment into configDidLoad and separating HTTP client lookup setup; removes the @eggjs/tegg dependency and updates test fixture plugin configs to match the new lifecycle structure.

Changes

Cohort / File(s) Summary
Plugin implementation
plugin/dns-cache/app.ts
Split lifecycle responsibilities: moved dnsResolver attachment into configDidLoad; adjusted placement of httpclient.lookup wiring.
Package manifest
plugin/dns-cache/package.json
Removed dependency: @eggjs/tegg from dependencies.
Test fixtures — remove teggController
plugin/dns-cache/test/fixtures/apps/dns_cache_lookup/config/plugin.js, plugin/dns-cache/test/fixtures/apps/dns_cache_resolve/config/plugin.js
Deleted teggController export from fixture plugin configs.
Test fixture — adjust exports
plugin/dns-cache/test/fixtures/apps/dns_cache_lookup_http_next/config/plugin.js
dnsCache: removed path property; teggController: replaced package with a path property and retained enable: true.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • killagu

Poem

🐇 I hopped through config, quick and spry,

Moved resolvers where they now belong,
Freed a dependency to say goodbye,
Fixtures updated, tidy and strong,
A little rabbit's lifecycle song.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: lifecycle for dns resolver initialization' directly and clearly describes the main change in the changeset: reorganizing when the DNS resolver is initialized within the application lifecycle.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0b8aaa and 4f71970.

📒 Files selected for processing (1)
  • plugin/dns-cache/package.json
💤 Files with no reviewable changes (1)
  • plugin/dns-cache/package.json
⏰ 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-ubuntu (20)
  • GitHub Check: Runner-macos (20)
  • GitHub Check: Runner-ubuntu (18)
  • GitHub Check: Runner-macos (16)
  • GitHub Check: Runner-ubuntu (16)
  • GitHub Check: Runner-macos (18)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 dns-cache plugin, ensuring its initialization occurs at an earlier, more appropriate phase. Concurrently, it streamlines the project's dependencies by removing plugins and packages that are no longer required, leading to a cleaner and potentially more efficient setup.

Highlights

  • DNS Resolver Lifecycle Adjustment: The initialization of the DNS resolver and the configuration of httpclient.lookup have been moved to an earlier stage in the application lifecycle, specifically from configDidLoad() to configWillLoad() (or equivalent early execution).
  • Unnecessary Dependency Removal: The @eggjs/tegg dependency has been removed from package.json, and the @eggjs/tegg-controller-plugin has been disabled/removed from several test fixture configurations.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

Copy link

@coderabbitai coderabbitai bot left a 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 configDidLoad method contains only a synchronous assignment and doesn't use await or 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9edf6d0 and e0b8aaa.

📒 Files selected for processing (5)
  • plugin/dns-cache/app.ts
  • plugin/dns-cache/package.json
  • plugin/dns-cache/test/fixtures/apps/dns_cache_lookup/config/plugin.js
  • plugin/dns-cache/test/fixtures/apps/dns_cache_lookup_http_next/config/plugin.js
  • plugin/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.lookup in configWillLoad ensures 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.

@Dipper30 Dipper30 force-pushed the fix/dns-cache-lifecycle branch from 4f71970 to d8f7f97 Compare January 8, 2026 04:00
@Dipper30 Dipper30 closed this Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants