Description
The cds.features.async_handler_compat flag previously allowed synchronous (non-async) event handler functions to be automatically wrapped into async context by the CAP framework. In CDS 10 this compat flag and its auto-wrapping behavior are removed. Synchronous handler functions registered with this.on(...), this.before(...), or this.after(...) using the function keyword (without async) must now be declared as async function explicitly or use an arrow function expression. Projects that relied on the auto-wrapping to make synchronous handlers work correctly in CAP's async event pipeline will see unexpected behavior or errors at runtime.
How to Check
- [ ] Check
cds envoutput forcds.features.async_handler_compat— its presence indicates the project explicitly relied on this behavior. - [ ] Search for
this.on(,this.before(,this.after(,srv.on(calls whose second argument is a plainfunction(...)without theasynckeyword. - [ ] Scan service implementation files in
srv/andlib/for non-async function expressions passed as event handlers.
Migration Steps
Add the
asynckeyword to non-async function expression handlers:diff- this.on('READ', Books, function(req) { - return this.db.read(Books); - }); + this.on('READ', Books, async function(req) { + return this.db.read(Books); + });Alternatively, convert to an async arrow function (the more common modern pattern):
diff- this.before('CREATE', Orders, function(req) { - req.data.createdAt = new Date(); - }); + this.before('CREATE', Orders, req => { + req.data.createdAt = new Date(); + });Remove the compat flag from CDS configuration:
diff// package.json or .cdsrc.json { "cds": { "features": { - "async_handler_compat": true } } }
Notes
The exact removal timing of this flag is not confirmed against the official CDS 10 changelog. Verify whether cds.features.async_handler_compat appears in the CDS 10 release notes before treating this as a required migration step. If the flag is still silently accepted (even if its behavior is gone), the runtime impact may be subtle rather than a hard failure.