Skip to content

refactor: simplify Effect server architecture - #108

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
codex/effect-server-architecture
Aug 27, 2026
Merged

refactor: simplify Effect server architecture#108
ScriptedAlchemy merged 1 commit into
mainfrom
codex/effect-server-architecture

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Collaborator

Summary

  • Create one scoped Effect ManagedRuntime for each plugin setup.
  • Let that runtime own route watchers, delayed lazy-compilation prewarm work,
    type generation, prerender workflows, background fibers, and finalizers.
  • Dispose resources in a deterministic, idempotent order from every Rsbuild
    shutdown path.
  • Keep PR perf: keep route transforms inline by default #86's newer inline/opt-in route-transform architecture; the removed
    bespoke transform worker is not reintroduced.
  • Update Effect to 3.22.0 and the Rstest 0.11.x range to at least 0.11.4.

Current-main repair

This branch was rebuilt from current main after #74 and #86 merged. It is now
a single commit and contains none of the obsolete pre-squash #74 history.
Conflict resolution preserves the verified RR8/RSC fixes from #74 and the
transform-loader design from #86.

Maintainability

  • One runtime creation site and one ordered shutdown policy.
  • Effect Scope, FiberSet, and ManagedRuntime replace manual watcher,
    delayed-task, and cleanup coordination.
  • Production src/ is 100 lines smaller than current main (631 additions,
    731 deletions).
  • The 1,232-line implementation plan was removed from the shipping diff.

Release

  • Adds a patch changeset describing the internal lifecycle improvement.
  • Existing changesets still determine the combined next package version.

Validation

  • pnpm test — 61 files and 639 tests passed, including all TypeScript
    project checks.
  • pnpm build.
  • pnpm test:package-interop.
  • pnpm e2e — all selected classic SSR, SPA, prerender, custom-server,
    Cloudflare, React Router 8, and RSC development/production examples passed.
  • pnpm format:check, pnpm changeset status, and git diff --check.
  • Emitted transform loaders and browser/RSC runtime templates are explicitly
    checked to contain no Effect imports.

Performance

This is a lifecycle/maintainability change, not a claimed hot-path speedup.
Effect remains outside emitted transform loaders and browser/runtime templates;
the current-head benchmark checks are left to CI rather than carrying forward
stale measurements from the old stacked branch.

@pkg-pr-new

pkg-pr-new Bot commented Aug 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/rsbuild-plugin-react-router@779d017

commit: 779d017

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark results

Case Base Head Delta
build-256-ssr 1994.3 ms 2001.2 ms +0.3%
dev-48-ssr 865.9 ms 852.1 ms -1.6%

@codspeed-hq

codspeed-hq Bot commented Aug 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 2 untouched benchmarks


Comparing codex/effect-server-architecture (779d017) with main (0dd1fa8)

Open in CodSpeed

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

Copy link
Copy Markdown

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: 779d017fee

ℹ️ 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 +162 to +163
await configA.buildEnd?.(...args);
await configB.buildEnd?.(...args);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Run every merged buildEnd hook before rejecting

When multiple presets and/or the user config provide buildEnd, a rejection from configA.buildEnd now prevents configB.buildEnd from being invoked. The previous Promise.all/Effect.all composition started every merged hook, so this can skip required cleanup or artifact-finalization work whenever an earlier hook fails; preserve deterministic ordering if desired, but still attempt all hooks before propagating their failures.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in #109 with a regression test that fails when a later merged buildEnd hook is skipped. The follow-up preserves deterministic order, runs remaining hooks, and rethrows the first normalized failure.

@ScriptedAlchemy
ScriptedAlchemy merged commit c62ae2e into main Aug 27, 2026
9 of 10 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the codex/effect-server-architecture branch August 27, 2026 04:21
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.

1 participant