Skip to content

fix(server): provide sqlite client before migration setup#5

Merged
Josh-wt merged 1 commit intomainfrom
codex/fix-service-not-found-error
Apr 11, 2026
Merged

fix(server): provide sqlite client before migration setup#5
Josh-wt merged 1 commit intomainfrom
codex/fix-service-not-found-error

Conversation

@Josh-wt
Copy link
Copy Markdown
Owner

@Josh-wt Josh-wt commented Apr 11, 2026

Motivation

  • The startup setup layer (PRAGMAs + migrations) required the Effect SqlClient service but could run before the runtime sqlite client layer was provided, causing Service not found: effect/sql/SqlClient during dev.

Description

  • Reordered the SQLite persistence layer composition so the runtime sqlite client layer from makeRuntimeSqliteLayer is provided before the setup layer that uses SqlClient.
  • Applied the same ordering fix to both the file-backed makeSqlitePersistenceLive and the in-memory SqlitePersistenceMemory layer builders.
  • Changes are limited to apps/server/src/persistence/Layers/Sqlite.ts and only affect Layer.provideMerge ordering.

Testing

  • Attempted to run bun fmt, bun lint, and bun typecheck, but the execution environment lacks Bun (bun: command not found), so those automated checks could not be executed here.
  • Static inspection and local compile-time ordering reasoning indicate the SqlClient service will be available to setup at runtime after this change.

Codex Task


Summary by cubic

Ensure the runtime SQLite client layer is provided before migrations/setup so effect/sql/SqlClient is available, fixing the "Service not found: effect/sql/SqlClient" error in dev.
Reordered Layer.provideMerge in makeSqlitePersistenceLive and SqlitePersistenceMemory to provide makeRuntimeSqliteLayer before setup.

Written for commit f44e39f. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Reorganized internal code structure for improved maintainability (no functional changes).

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b163006-e291-4043-8fef-43b49588f2ef

📥 Commits

Reviewing files that changed from the base of the PR and between 31ee360 and f44e39f.

📒 Files selected for processing (1)
  • apps/server/src/persistence/Layers/Sqlite.ts

📝 Walkthrough

Walkthrough

The SQLite persistence layer's Layer.provideMerge calls are refactored to reorder arguments, moving the setup parameter from the first to the last position in both makeSqlitePersistenceLive and SqlitePersistenceMemory functions, with no changes to logic or behavior.

Changes

Cohort / File(s) Summary
SQLite Layer Argument Reordering
apps/server/src/persistence/Layers/Sqlite.ts
Reorder arguments in Layer.provideMerge calls: move setup parameter from first to last position in both makeSqlitePersistenceLive and SqlitePersistenceMemory. No functional changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

🐰 A hop, a skip, we rearrange,
Arguments dance in ordered range,
Setup moves back with gentle care,
Persistence flows through functions fair! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-service-not-found-error

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.

@Josh-wt Josh-wt merged commit 6d1c5d1 into main Apr 11, 2026
1 of 2 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f44e39f16c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 45 to 47
return Layer.provideMerge(
setup,
makeRuntimeSqliteLayer({
filename: dbPath,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pass setup as the dependent layer in provideMerge

In apps/server/src/persistence/Layers/Sqlite.ts, this call now uses the two-arg Layer.provideMerge overload with arguments reversed. In Effect, that overload is provideMerge(that, self), so putting makeRuntimeSqliteLayer(...) first feeds setup into the runtime layer instead of feeding the runtime SqlClient into setup. That leaves setup without SqlClient at build time and can reproduce the original Service not found: effect/sql/SqlClient startup failure (the same inversion is repeated in SqlitePersistenceMemory).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant