fix: serialize repository refreshes and recover stale downloads - #842
Conversation
|
@codex review |
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0002e8d1a1
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Overlapping dashboard refreshes could both start GitHub work and overwrite a removal requested while that work was running. The refresh guard also rejected stale downloads indefinitely.
Claim a five-minute MongoDB lease before refreshing, guard refresh writes against lease and lifecycle changes, and release only the request's own lease. Downloads older than five minutes can be retried only when BullMQ has no live job. Save the new commit and PREPARING status atomically; failed preparations remain retryable. Ready snapshots stay available during GitHub lookups.
Addresses the concurrency and stale-download findings from the second Codex review of #841. The reported missing polling endpoint already exists; an HTTP routing test confirms GET /api/repo/:repoId returns status through the mounted routers, including when GitHub credentials are unavailable.
Validation: 91 focused tests pass, including overlapping refreshes, lease replacement, removal/expiry/archive races, restoration, and polling. Changed files pass ESLint. TypeScript checking reports only the existing errors in unchanged files.