Conversation
There was a problem hiding this comment.
The change is clear and correct. The async inner callback in cds.tx(...) already returns a Promise, but without await the outer rescan function would not wait for the transaction to commit before proceeding to spawn the scan event and throw. Adding await ensures the status is persisted before the next steps execute — exactly the fix described.
The implementation looks correct. No issues to flag.
The PR is a minimal, focused fix: adding await to cds.tx(...) ensures the "Scanning" status is committed to the database before the scan event is emitted and the 202 error is thrown, correctly resolving the race condition described in the PR.
PR Bot Information
Version: 1.20.37
- LLM:
anthropic--claude-4.6-sonnet - Correlation ID:
c9b54f16-4421-411e-8865-1081a48c2bb6 - Event Trigger:
pull_request.opened - File Content Strategy: Full file content
|
Scanning status is only set in 2 places. Since scanAttachmentsFile always sets the status before it can become clean, that means cds.tx is resolving late under load and thus setting the status to "Scanning" after the scan. |
SummaryThe following content is AI-generated and provides a summary of the pull request: Fix Race Condition in Duplicate Scan PreventionBug Fix🐛 Removed a redundant function call that was setting the scan status to Changes
PR Bot InformationVersion:
|
There was a problem hiding this comment.
The analysis is complete. The scanAttachmentsFile handler in malwareScanner.js calls await this.updateStatus(_target, keys, "Scanning") at line 72 as its first substantive action inside a committed transaction. The deleted cds.tx(...) call in generic-handlers.js was fire-and-forget (no await), meaning it ran asynchronously in a separate transaction that could resolve after the scan had already completed — which is exactly the race condition described in the PR comment.
Now let me check the CHANGELOG entry wording against the actual change:
The CHANGELOG says "Fixed: Remove extra function setting status to scanning to avoid race conditions." The PR description says "Await setting the scan status to 'scanning' to avoid race condition." The actual fix removes the duplicate, not awaits anything — the CHANGELOG wording is accurate, but the PR description is misleading. That's just a description issue, not a code issue.
The code change itself looks correct. No substantive code issues to flag.
The PR is a clean, well-reasoned fix. The unawaited cds.tx(...) call was correctly identified as the source of the race condition, and removing it is the right solution since scanAttachmentsFile already sets status to "Scanning" as its first committed step. No code defects were found.
PR Bot Information
Version: 1.20.43
- Correlation ID:
f51bd84a-d48d-4fb4-9e11-42b0c717dde5 - File Content Strategy: Full file content
- Event Trigger:
pull_request.ready_for_review - LLM:
anthropic--claude-4.6-sonnet
Await setting the scan status to 'scanning' to avoid race condition.