Repository navigation
fix(trash): repair delete, restore, and sync flows - #292
NeerajCodz wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efcb68e3fc
ℹ️ 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".
| const category = await ctx.db.get(args.categoryId); | ||
| if (!category || category.ownerId !== args.userId || category.archivedAt === undefined) return; |
There was a problem hiding this comment.
Tie continuation jobs to the originating archive
When a category with more than 50 transactions is restored and then archived again with “keep transactions” before a delayed continuation runs, this check sees only that the category is currently archived and lets the old job continue deleting the remaining transactions. Compare the current trashedAt with args.now (or use another archive-generation token) so work scheduled by an earlier archive cannot affect the category's new state.
Useful? React with 👍 / 👎.
| (error: unknown) => { | ||
| console.warn('[local-sync] Could not mark the opened notification read.', error); | ||
| setTimeout(() => markQueued(id), 1_000); |
There was a problem hiding this comment.
Bound retries for failed push-read acknowledgements
If marking a queued notification read fails permanently—for example because the notification ID is stale or the user no longer has access—this schedules another attempt every second forever. The timers are neither capped nor cancelled when the effect is cleaned up, and a later userId change can start an additional retry chain for the same ID, causing persistent network traffic and log spam; use bounded/backed-off retries with cleanup or leave the entry for a later explicit sync attempt.
Useful? React with 👍 / 👎.
| if (row.ownerId !== args.userId || row.groupId !== undefined) continue; | ||
| await purgeTransaction(ctx, args.userId, row, args.now); |
There was a problem hiding this comment.
Preserve accounts referenced by active group expenses
When an archived account is purged while an undeleted group expense still uses it, this unconditional group-row skip leaves the live transaction in place and the continuation eventually deletes its required account. groups.updateExpense then rejects even an edit that keeps the existing account because ctx.db.get(args.accountId) returns null, so either block the account purge or explicitly handle active group expenses while retaining only ledger tombstones.
Useful? React with 👍 / 👎.
| let cursor: string | null = null; | ||
| while (items.length < limit) { | ||
| const page = await ctx.db |
There was a problem hiding this comment.
Bound scans while filtering group tombstones
For a user with many deleted group expenses and few or no personal trashed transactions, this loop paginates through every group tombstone before returning. Because group tombstones are deliberately excluded from expiry, they can accumulate indefinitely until trash.list or trash.empty exceeds Convex query read/byte limits and fails; use an index that excludes group rows or impose a bounded scan rather than looping to isDone.
Useful? React with 👍 / 👎.
| if (!sourcePage.isDone || !transferPage.isDone) { | ||
| await ctx.scheduler.runAfter(0, internal.trash.continueAccountPurge, { | ||
| ...args, | ||
| sourceCursor: sourcePage.isDone ? null : sourcePage.continueCursor, | ||
| transferCursor: transferPage.isDone ? null : transferPage.continueCursor, | ||
| }); | ||
| return { purged, done: false }; |
There was a problem hiding this comment.
Prevent restores while an account purge is in progress
For an account with more than one transaction page, this mutation permanently deletes the first page, schedules the remainder, and returns while the archived account is still visible and restorable. If the user restores it before the continuation runs—especially when scheduled work is delayed—the continuation aborts because archivedAt was cleared, leaving a restored account with part of its transaction history permanently missing; mark the account as purging or otherwise make the purge atomic from the restore API's perspective.
Useful? React with 👍 / 👎.
- Filter and cap personal trash rows without unbounded collection. - Process account and transfer transaction indexes in separate scheduled phases. - Return explicit nulls in the category restore test fixture.
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
- Await the transfer-index phase before asserting all account records were removed.
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
- Supply the fake-timer advancement callback when draining scheduled purge jobs.
Changes
Issues
Fixes #228
Fixes #229
Fixes #230
Fixes #231
Fixes #232
Fixes #233
Fixes #234
Fixes #235
Fixes #236
Fixes #237
Fixes #239
Fixes #281