Expand how much of the codebase is using Effect; fix excess error emission (take 2)#271
Merged
Expand how much of the codebase is using Effect; fix excess error emission (take 2)#271
Conversation
Use SqliteClient.make with Layer.scoped so the connection lifetime is tied to the layer scope (Effect.scoped was closing it immediately). Inline PRAGMA busy_timeout into the layer construction. Convert integrity check to Effect.repeat(Schedule) and checkpointWal to return an Effect. Remove runtime, bridge functions, and shutdown helpers that move to AppRuntime in the next commit. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move ManagedRuntime, layer composition, and bridge functions (db, run, runTakeFirst, runTakeFirstOrThrow, posthogClient) from Database.ts into a dedicated AppRuntime.ts. The AppLayer now includes DatabaseLayer, PostHogServiceLive, and FeatureFlagServiceLive. Update all consumer imports to use #~/AppRuntime. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wrap the startup sequence in an Effect.gen pipeline: init Discord gateway, fork integrity check as a daemon fiber, register commands, and wire up graceful shutdown (WAL checkpoint + runtime dispose). Convert gateway init and registerCommand to return Effects so they compose into the startup pipeline. Move shutdown handler from gateway to server.ts where the runtime is available. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Smoke Test Results
Tested commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Swaps out the way the database loads, and shift more responsibility for startup into AppRuntime (an Effect).
This also reworks how the database is initalized, which might help with some of the weirdo oddball failures we've been seeing. I'm using a new creation mechanism, and it demanded I explciitly provide a "Scope" reference. I think this is going to mean that all access relies on the same connection, which has been the main problem so far.
This failed the last time because of a webserver startup issue that I missed. This PR now includes a CI change that ensures the pod starts correctly in staging.
There's still an issue with the webserver I'm resolving