diff --git a/src/backend/replication/logical/logicalctl.c b/src/backend/replication/logical/logicalctl.c
index 4a690a631da..e647cd74c27 100644
--- a/src/backend/replication/logical/logicalctl.c
+++ b/src/backend/replication/logical/logicalctl.c
@@ -429,6 +429,11 @@ EnableLogicalDecoding(void)
  *
  * Note that this function does not verify whether logical slots exist. The
  * checkpointer will verify if logical decoding should actually be disabled.
+ *
+ * This may be called during recovery, for example when a standby invalidates
+ * its last valid logical slot. That is safe because the queued request is only
+ * acted upon outside recovery. See the RecoveryInProgress() check in
+ * DisableLogicalDecodingIfNecessary().
  */
 void
 RequestDisableLogicalDecoding(void)
@@ -471,6 +476,14 @@ DisableLogicalDecodingIfNecessary(void)
 	 */
 	Assert(!MyReplicationSlot);
 
+	/*
+	 * During recovery the logical decoding status follows the primary via WAL
+	 * replay, so we must not disable it here. A pending_disable request queued
+	 * during recovery, for example by a local slot invalidation, is
+	 * intentionally left for the end-of-recovery transition or the
+	 * post-promotion checkpointer to act on. See
+	 * UpdateLogicalDecodingStatusEndOfRecovery().
+	 */
 	if (RecoveryInProgress())
 		return;
 
