Hello
> This is not the case also when the backup is made from the primary?
On primary it is handled in do_pg_backup_stop function (called from perform_base_backup after basebackup was transferred), without explicitly called pg_switch_wal from pg_basebackup. pg_basebackup can change this behavior using options to the BASE_BACKUP replication command.
regards, Sergei