Skip to content

Add RPC Post/User resolver-cache leak reproduction coverage across 100 requests#766

Closed
Copilot wants to merge 7 commits into
mainfrom
copilot/extend-rpc-tests-with-user-relation
Closed

Add RPC Post/User resolver-cache leak reproduction coverage across 100 requests#766
Copilot wants to merge 7 commits into
mainfrom
copilot/extend-rpc-tests-with-user-relation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 24, 2026

This extends RPC ContextMap streaming coverage with a relational Post/User scenario (100 posts, author/publisher + likes) resolved through withRequestResolverCache. It adds a targeted repro that runs 100 requests and demonstrates cross-request cache retention under a deliberately leaky request-context wiring (users/fibers effectively retained via shared request cache scope).

  • Problem coverage

    • Adds a high-cardinality relational fixture to exercise nested request-resolver caching in realistic fan-out shape (authorUserId, publisherUserId, likes[].likeUserId).
    • Drives repeated request pressure (100 calls) to surface retention behavior that would not appear in single-request checks.
  • RPC test fixture expansion

    • Introduces LeakUser, LeakPost, LeakLike, and LeakProbePosts in rpc-context-map-streaming.test.ts.
    • Seeds 100 users/posts; each post references 12 user IDs (2 direct + 10 likes).
  • Leaky scope repro path

    • Adds a leaky middleware layer that intentionally shares one ContextMap across requests.
    • Uses withRequestResolverCache around a batched GetLeakUser resolver to model per-request cache behavior under incorrect scope binding.
  • Leak signal assertions

    • Verifies first request resolves the full relation fan-out.
    • Verifies subsequent 99 requests do not increase resolver fetch count, indicating cross-request cache reuse/retention in the leaky setup.
  • Release note

    • Adds an infra changeset: .changeset/rpc-leak-repro-post-user.md.
const first = yield* client.LeakProbePosts.handler()
expect(first).toBe(LEAK_USER_COUNT * (LEAK_USER_REFS_PER_POST + LEAK_LIKES_PER_POST))

const resolverUsersAfterFirstRequest = leakStats.resolverRequestedUsers
yield* Effect.forEach(
  Array.from({ length: LEAK_REQUEST_COUNT - 1 }, () => undefined),
  () => client.LeakProbePosts.handler(),
  { discard: true }
)

expect(leakStats.resolverRequestedUsers).toBe(resolverUsersAfterFirstRequest)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 24, 2026

Open in StackBlitz

@effect-app/cli

npm i https://pkg.pr.new/effect-app/libs/@effect-app/cli@766

effect-app

npm i https://pkg.pr.new/effect-app/libs/effect-app@766

@effect-app/eslint-codegen-model

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-codegen-model@766

@effect-app/eslint-shared-config

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-shared-config@766

@effect-app/infra

npm i https://pkg.pr.new/effect-app/libs/@effect-app/infra@766

@effect-app/vue

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue@766

@effect-app/vue-components

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue-components@766

commit: d363114

@patroza patroza closed this May 24, 2026
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.

2 participants