Skip to content

🐛 Avoid duplicating inherited API middleware - #1226

Open
taras wants to merge 1 commit into
v4from
agent/fix-api-inheritance
Open

🐛 Avoid duplicating inherited API middleware#1226
taras wants to merge 1 commit into
v4from
agent/fix-api-inheritance

Conversation

@taras

@taras taras commented Aug 7, 2026

Copy link
Copy Markdown
Member

Motivation

When a child scope adds contextual API middleware after inheriting middleware from its parent, Effection 4.1 stores the inherited middleware as part of the child's local decoration. If the parent later adds more middleware, propagation recomputes the inherited total and applies the original parent middleware twice.

This blocks @effectionx/context-api from delegating to Effection's experimental createApi without regressing its existing live-parent middleware guarantees.

Approach

  • Separate the inherited middleware total from child-local middleware when a scope first decorates an API.
  • Keep later ancestor propagation live while ensuring each inherited middleware appears exactly once.
  • Add a regression test covering parent middleware installed both before and after a child installs its own middleware.

Verification

  • deno task test — 37 suites, 234 steps passed
  • deno lint
  • deno check mod.ts experimental.ts
  • deno fmt lib/api-internal.ts test/api.test.ts
  • deno task build:npm 4.1.1

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/effection@1226

commit: 626c8cf

@codspeed-hq

codspeed-hq Bot commented Aug 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing agent/fix-api-inheritance (626c8cf) with v4 (70ddc1c)

Open in CodSpeed

@taras
taras requested a review from cowboyd August 7, 2026 13:37
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deploy Preview Ready!

@taras
taras marked this pull request as ready for review August 7, 2026 13:38
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