diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index f7acd709b26808..dfad3f4a6186f2 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -327,7 +327,12 @@ class CommandHandler { return CHIP_NO_ERROR; } - ReturnErrorOnFailure(RollbackResponse()); + // The error value of RollbackResponse is not important if it fails, we prioritize + // conveying the error generated by addResponseFunction to the caller. + if (RollbackResponse() != CHIP_NO_ERROR) + { + return err; + } // If we failed to add a command due to lack of space in the // packet, we will make another attempt to add the response using // an additional InvokeResponseMessage.