From 65d1bc89d372fce9301cc7cc78c337c15764c734 Mon Sep 17 00:00:00 2001 From: Eric Peairs Date: Wed, 6 May 2026 10:51:48 +0200 Subject: [PATCH 1/5] Await scanning --- lib/generic-handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generic-handlers.js b/lib/generic-handlers.js index 1860f41d..b6c78869 100644 --- a/lib/generic-handlers.js +++ b/lib/generic-handlers.js @@ -190,7 +190,7 @@ async function rescan(req, attachmentId) { const malwareScanner = await cds.connect.to("malwareScanner") // Set status to Scanning and commit before emitting event to prevent race conditions - cds.tx( + await cds.tx( async () => await malwareScanner.updateStatus(target, keys, "Scanning"), ) From a84c6bfd4eda151ea3222b9b649ac1a52b684ebd Mon Sep 17 00:00:00 2001 From: Eric Peairs Date: Wed, 6 May 2026 10:54:26 +0200 Subject: [PATCH 2/5] Changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 654a1645..edc2e62b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). The format is based on [Keep a Changelog](http://keepachangelog.com/). +## Version 3.13.0 + +### Fixed + +- Await function setting status to scanning to avoid race conditions. + ## Version 3.12.1 ### Added From af46975cd227d2ee4c4b090394c6580467fa9c46 Mon Sep 17 00:00:00 2001 From: Eric Peairs Date: Wed, 6 May 2026 11:41:18 +0200 Subject: [PATCH 3/5] Remove deadlock --- lib/generic-handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generic-handlers.js b/lib/generic-handlers.js index b6c78869..1860f41d 100644 --- a/lib/generic-handlers.js +++ b/lib/generic-handlers.js @@ -190,7 +190,7 @@ async function rescan(req, attachmentId) { const malwareScanner = await cds.connect.to("malwareScanner") // Set status to Scanning and commit before emitting event to prevent race conditions - await cds.tx( + cds.tx( async () => await malwareScanner.updateStatus(target, keys, "Scanning"), ) From bf2be97f1ee0c0de9c976f19443585579cdd299f Mon Sep 17 00:00:00 2001 From: Eric Peairs Date: Wed, 6 May 2026 13:26:32 +0200 Subject: [PATCH 4/5] Remove cds.tx --- lib/generic-handlers.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/generic-handlers.js b/lib/generic-handlers.js index 1860f41d..9b2063f4 100644 --- a/lib/generic-handlers.js +++ b/lib/generic-handlers.js @@ -189,12 +189,6 @@ async function rescan(req, attachmentId) { // No scan or scan expired: trigger scan and reject const malwareScanner = await cds.connect.to("malwareScanner") - // Set status to Scanning and commit before emitting event to prevent race conditions - cds.tx( - async () => await malwareScanner.updateStatus(target, keys, "Scanning"), - ) - - // Trigger scanning in separate transaction as req.reject closes the current transaction cds.spawn(async () => { await malwareScanner.emit("ScanAttachmentsFile", { target, From 00191fb4611c2e0f91ef5e72f226fb4fca2b19ad Mon Sep 17 00:00:00 2001 From: Eric Peairs Date: Wed, 6 May 2026 13:29:17 +0200 Subject: [PATCH 5/5] Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edc2e62b..6d87b96c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). ### Fixed -- Await function setting status to scanning to avoid race conditions. +- Remove extra function setting status to scanning to avoid race conditions. ## Version 3.12.1