Conversation
|
📝 WalkthroughWalkthroughThis PR refactors database singleton access patterns across the ENS API from lazy property proxies to runtime getter functions. The singleton module now exports Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR replaces Key changes:
Confidence Score: 5/5Safe to merge — the refactor is mechanically consistent across all call sites and correctly addresses a known Drizzle-Proxy incompatibility. No logic bugs, data-loss risks, or security concerns found. Every consumer has been updated from the module-level proxy pattern to the function-call pattern at request/invocation time. The lazy caching in the lazy() helper ensures no redundant DB initialization on repeated calls. All remaining observations are P2 style-level. No files require special attention — the refactor is uniform and low-risk. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
ENV[Environment Variables] --> ensDbClient
ensDbClient["ensDbClient - lazyProxy wrapping EnsDbReader"] --> getEnsDb
ensDbClient --> getEnsIndexerSchema
getEnsDb["getEnsDb - lazy getter function"] --> Queries["DB Queries - GraphQL resolvers, finders, analytics"]
getEnsIndexerSchema["getEnsIndexerSchema - lazy getter function"] --> Schema["Schema References - type-safe column access"]
subgraph Before
B1["ensDb = lazyProxy(...)"] --> B2["Drizzle introspection fails - Proxy intercepts symbols and keys"]
end
subgraph After
A1["getEnsDb = lazy(...)"] --> A2["Real Drizzle object - introspection works correctly"]
end
Reviews (1): Last reviewed commit: "replace lazyProxy" | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ensapi/src/config/config.singleton.test.ts`:
- Line 25: Update the stale test comments that call ensDbClient a "lazyProxy" to
reflect the current design: describe these exports (ensDbClient, getEnsDb,
getEnsIndexerSchema) as lazy getter exports or lazy exports instead of
"lazyProxy"; locate the comments adjacent to the import line for
ensDbClient/getEnsDb/getEnsIndexerSchema and the comment block covering lines
~30-33 and replace wording so it consistently refers to "lazy getter exports"
(or equivalent) to match the PR migration language.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 16daed26-ba13-483c-82ed-5fb774b0dda8
📒 Files selected for processing (37)
apps/ensapi/src/config/config.singleton.test.tsapps/ensapi/src/graphql-api/lib/find-domains/canonical-registries-cte.tsapps/ensapi/src/graphql-api/lib/find-domains/find-domains-resolver.tsapps/ensapi/src/graphql-api/lib/find-domains/layers/base-domain-set.tsapps/ensapi/src/graphql-api/lib/find-domains/layers/filter-by-canonical.tsapps/ensapi/src/graphql-api/lib/find-domains/layers/filter-by-name.tsapps/ensapi/src/graphql-api/lib/find-domains/layers/filter-by-owner.tsapps/ensapi/src/graphql-api/lib/find-domains/layers/filter-by-parent.tsapps/ensapi/src/graphql-api/lib/find-domains/layers/filter-by-registry.tsapps/ensapi/src/graphql-api/lib/find-domains/layers/with-ordering-metadata.tsapps/ensapi/src/graphql-api/lib/find-events/find-events-resolver.tsapps/ensapi/src/graphql-api/lib/get-canonical-path.tsapps/ensapi/src/graphql-api/lib/get-domain-by-interpreted-name.tsapps/ensapi/src/graphql-api/lib/get-domain-resolver.tsapps/ensapi/src/graphql-api/lib/get-latest-registration.tsapps/ensapi/src/graphql-api/schema/account.tsapps/ensapi/src/graphql-api/schema/domain.tsapps/ensapi/src/graphql-api/schema/event.tsapps/ensapi/src/graphql-api/schema/label.tsapps/ensapi/src/graphql-api/schema/permissions.tsapps/ensapi/src/graphql-api/schema/query.tsapps/ensapi/src/graphql-api/schema/registration.tsapps/ensapi/src/graphql-api/schema/registry-permissions-user.tsapps/ensapi/src/graphql-api/schema/registry.tsapps/ensapi/src/graphql-api/schema/renewal.tsapps/ensapi/src/graphql-api/schema/resolver-permissions-user.tsapps/ensapi/src/graphql-api/schema/resolver-records.tsapps/ensapi/src/graphql-api/schema/resolver.tsapps/ensapi/src/handlers/subgraph/subgraph-api.tsapps/ensapi/src/lib/ensanalytics/referrer-leaderboard/database-v1.tsapps/ensapi/src/lib/ensanalytics/referrer-leaderboard/database.tsapps/ensapi/src/lib/ensdb/singleton.tsapps/ensapi/src/lib/name-tokens/find-name-tokens-for-domain.tsapps/ensapi/src/lib/protocol-acceleration/find-resolver.tsapps/ensapi/src/lib/protocol-acceleration/get-primary-name-from-index.tsapps/ensapi/src/lib/protocol-acceleration/get-records-from-index.tsapps/ensapi/src/lib/registrar-actions/find-registrar-actions.ts
|
|
||
| it("constructs EnsDbReader from real env wiring without errors", async () => { | ||
| const { ensDbClient, ensDb, ensIndexerSchema } = await import("@/lib/ensdb/singleton"); | ||
| const { ensDbClient, getEnsDb, getEnsIndexerSchema } = await import("@/lib/ensdb/singleton"); |
There was a problem hiding this comment.
Update stale lazyProxy terminology in adjacent test comments.
This block now verifies lazy getter exports, but nearby comments still describe ensDbClient as lazyProxy, which conflicts with the PR’s migration language and makes intent harder to follow.
✏️ Suggested comment cleanup
- // ensDbClient is a lazyProxy — construction is deferred until first property access.
+ // ensDbClient is lazily initialized — construction is deferred until first property access.
@@
- // ensDbClient is a lazyProxy — import succeeds but first property access triggers construction,
+ // ensDbClient is lazily initialized — import succeeds but first property access triggers construction,
@@
- // ensDbClient is a lazyProxy — import succeeds but first property access triggers construction,
+ // ensDbClient is lazily initialized — import succeeds but first property access triggers construction,Also applies to: 30-33
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/ensapi/src/config/config.singleton.test.ts` at line 25, Update the stale
test comments that call ensDbClient a "lazyProxy" to reflect the current design:
describe these exports (ensDbClient, getEnsDb, getEnsIndexerSchema) as lazy
getter exports or lazy exports instead of "lazyProxy"; locate the comments
adjacent to the import line for ensDbClient/getEnsDb/getEnsIndexerSchema and the
comment block covering lines ~30-33 and replace wording so it consistently
refers to "lazy getter exports" (or equivalent) to match the PR migration
language.
Summary
remove lazyProxy with lazy for drizzle
Why
Testing
Notes for Reviewer (Optional)
Pre-Review Checklist (Blocking)