In order to perform this refineCollectionShardKey, the shard will try to refresh the collection information from the configsvr using majority read concern and nearest preference. This could fail if the shard tries to refresh from the configsvr secondary that has replication stopped, as it could not satisfy the read concern.
Currently the refine_collection_shard_key_abort_on_stepup.js test is only awaiting replication before sharding the collection. Later the collection is sharded and then replication stops on the configsvr secondary, with may not have replicated it.
The proposal is to introduce an awaitReplication() call after the shardCollection.