Move recalculate analyze/upsert off the main thread#205
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughこのPRはPR分析とDBアップサートをワーカースレッドへ分離する変更を導入し、パスエイリアス解決フック、ワーカー実行ユーティリティ、ワーカー本体(analyze/upsert)、ビルドスクリプト、及びレビュアーのバッチ置換を追加します。 Changes
Sequence DiagramsequenceDiagram
participant Main as Main Thread
participant AnalyzeW as Analyze Worker
participant PRBuilder as Store/PR Builder
participant UpsertW as Upsert Worker
participant DB as Database
Main->>AnalyzeW: runAnalyzeInWorker({ organizationId, repositoryId, ... })
activate AnalyzeW
AnalyzeW->>PRBuilder: initialize store (org/repo)
PRBuilder-->>AnalyzeW: store ready
AnalyzeW->>PRBuilder: buildPullRequests(input, filterPrNumbers?)
PRBuilder-->>AnalyzeW: { pulls, reviews, reviewers, reviewResponses }
AnalyzeW-->>Main: postMessage(AnalyzeResult)
deactivate AnalyzeW
Main->>UpsertW: runUpsertInWorker({ organizationId, pulls, reviews, reviewers })
activate UpsertW
UpsertW->>DB: upsertAnalyzedData(orgId, data)
DB->>DB: batchReplacePullRequestReviewers(rows)
DB-->>UpsertW: { ok: true }
UpsertW-->>Main: postMessage({ ok: true })
deactivate UpsertW
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
a552c93 to
7a30be2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/services/jobs/run-in-worker.ts`:
- Around line 61-65: The exit handler currently ignores exit code 1
(worker.on('exit', (code) => { if (code !== 0 && code !== 1) ... })), so a
worker that exits with code 1 won't cause rejection; update the check in the
worker.on('exit') callback used in run-in-worker.ts to treat any non-zero code
as an error (e.g., use code !== 0), and ensure the reject call includes the exit
code in the Error message to preserve context.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bdb4ffd8-dcc7-4eed-81d4-96c0d18c5ed0
📒 Files selected for processing (7)
app/services/jobs/analyze-worker.tsapp/services/jobs/path-alias-hooks.mjsapp/services/jobs/run-in-worker.tsapp/services/jobs/shared-steps.server.tsapp/services/jobs/upsert-worker.tsbatch/db/mutations.tspackage.json
6242d1d to
34b3d3a
Compare
34b3d3a to
18b5a93
Compare
Summary
Validation
node --import tsx batch/cli.ts recalculate aScaf_RvvFiOJWD3m8X32338 PRs updatedSummary by CodeRabbit
リリースノート
New Features
Refactor
Chores
Tests