Skip to content

fix(client): prevent stale reads from restoring deleted sessions - #56886

Closed
Kyle-j-bush wants to merge 2 commits into
anomalyco:devfrom
Kyle-j-bush:session-deletion
Closed

Kyle-j-bush wants to merge 2 commits into
anomalyco:devfrom
Kyle-j-bush:session-deletion

Conversation

@Kyle-j-bush

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #56736

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Ignore sessions deleted while metadata or family reads are in flight. Deletions are tracked only until each read settles, preventing stale responses from restoring deleted records or marking them synchronized.

How did you verify your code works?

  • Both regression cases fail before the fix and pass afterward.
  • Client: 231 tests pass; the regression file passes 10 randomized runs.
  • TUI data: 50 tests pass.
  • bun run check passes, with existing lint warnings.

Screenshots / recordings

No visual layout change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I found no problems that should block a merge. On the base, the reproduction from #56736 (real createData and generated client, with a mocked fetch and an in-memory event bus) brings back the deleted session both after a delayed metadata read and after a delayed family read. With this change, both stay deleted, and a later sync of the deleted child sends its own request again. The packages/client tests (231) and the type check pass.

I also checked the timing cases. When a sync is skipped because a read is already running, or waits for an earlier read to finish, deletions are still caught by the read that actually runs. A deleted parent's family read is not marked complete. A delete that arrives after the response is written still removes the session.

Public API: unchanged (internal to createData).

One small point on the new test: the test.each over metadata/family repeats kind === "family" in about seven places (fetch routing, fixtures, assertions), which makes it hard to follow. Two short plain tests would be clearer.

@Kyle-j-bush

Copy link
Copy Markdown
Contributor Author

Split the test into two different test following the comment from the bot

@Kyle-j-bush

Copy link
Copy Markdown
Contributor Author

Looks like there are two different PRs on #56736, PR #56751 fixes a different problem, Eviction clears messages from memory but does not actually delete the session. Mine (#56886) fixes this issue by preventing stale data from restoring a deleted session from cache

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.

client: delayed metadata and family reads resurrect deleted sessions in the client cache

1 participant