Conversation
… NodeSqliteClient Layer.effectServices does not exist in Effect 4.0.0-beta.43. Calling it throws TypeError at layer build time, which Effect catches as a defect, silently failing the sqlite client layer. This left setup's yield* SqlClient.SqlClient with no service in context, producing the misleading "Service not found: effect/sql/SqlClient" error. The correct API (confirmed from @effect/sql-sqlite-bun reference impl) is: - Layer.scopedContext for scoped resources (sqlite conn needs Scope cleanup) - Context.make(Client.SqlClient, client) instead of ServiceMap.make/add https://claude.ai/code/session_01BpwxjJ9XzBeAXjRp86E9Jr
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR refactors the SQL client service layer construction in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
Root cause
Layer.effectServicesdoes not exist in Effect 4.0.0-beta.43. Calling it at layer build time throwsTypeError: undefined is not a function, which Effect catches as a defect and silently fails the sqlite client layer. With noSqlClient.SqlClientregistered in context, thesetuplayer'syield* SqlClient.SqlClientthrows the misleading "Service not found: effect/sql/SqlClient" error.Fix
Replace all three
Layer.effectServices(...)calls inNodeSqliteClient.tswithLayer.scopedContext(...)+Context.make(Client.SqlClient, client).This matches the pattern used by the
@effect/sql-sqlite-bunreference implementation:Layer.scopedContextis the correct API for scoped resources (the sqlite connection registers aScopefinalizer to close the DB)Context.make/Context.addregister services in the Effect context that downstream layers can findTest plan
cd apps/server && bun run devstarts without the "Service not found: effect/sql/SqlClient" errorhttps://claude.ai/code/session_01BpwxjJ9XzBeAXjRp86E9Jr
Summary by cubic
Fix server startup by replacing
Layer.effectServiceswithLayer.scopedContextinNodeSqliteClient. This registersClient.SqlClientcorrectly and removes the "Service not found: effect/sql/SqlClient" error.Layer.scopedContextfor the sqlite scoped resource andContext.make(Client.SqlClient, client)to register the service.@effect/sql-sqlite-bun; avoids the runtimeTypeErrorfrom missingLayer.effectServicesineffect@4.0.0-beta.43.Written for commit 83c09e0. Summary will update on new commits.
Summary by CodeRabbit