"And Gerson (De spirituali vita animae, lect.) 4) appears to be of the same view. "Doctors are unanimous," says he, "that in matters of the divine law there is no room for invincible ignorance, seeing that God will always help him who does what in him lies, and He is ready to enlighten the mind as far as will be necessary for salvation and the avoidance of error." And Hugo de Sancto Victore (bk. 2, pt. 6, ch.5) says that none is excused by ignorance for breach of the command to receive baptism, for he could have heard and known, had it not been for his own fault, as was the case with Cornelius (Cornelius the Centurion) (Acts, ch. 10). SourceAdrian gives precision to this doctrine, in his Quodlibeta, qu. 4. "There is," says he, "a two-fold distinction in matters of the divine law. There are some matters to the knowledge of which God does not oblige every one universally, such as the nice problems of the divine law and difficulties with regard to this law and with regard to Holy Scripture and the Commandments; in these matters there may well be a case of invincible ignorance, even if a man does all that in him lies. There are other matters
to the knowledge of which God obliges all men generally, such as the articles of faith and the universal commandments of the law; of these it is true, as the doctors assert, that ignorance thereof is not excused. For if any one does what in him lies, he will be illuminated of God through either the doctor that is within him or a doctor from without."... "But the mistake which the doctors in question [doctors holding opposite view to the above] make is in thinking that when we postulate invincible ignorance on the subject of baptism or of the Christian faith, it follows at once that a person can be saved without baptism or the Christian faith, which, however, does not follow. For the aborigines to whom no preaching of the faith or Christian religion has come will be damned for mortal sins or for idolatry, but not for the sin of unbelief, as St. Thomas (Secunda Secundae, as above) says, namely, that if they do what in them lies, accompanied by a good life according to the law of nature, it is consistent with God's providence and He will illuminate them regarding the name of Christ, but it does not therefore follow that if their life be bad, ignorance or unbelief in baptism and the Christian faith may be imputed to them as a sin.
St. Thomas Aquinas:
St. Thomas Aquinas, De Veritate, 14, A. 11, ad 1: Objection- “It is possible that someone may be brought up in the forest, or among wolves; such a man cannot explicitly know anything about the faith.
Answer: It is the characteristic of Divine to provide every man with what is necessary for salvation… provided on his part there is no hindrance. In the case of a man who seeks good and shuns evil, by the leading of natural reason, God would either reveal to him through internal inspiration what had to be believed, or would send some preacher of the faith to him…”[cclvi] Providence
St. Thomas Aquinas, Sent. II, 28, Q. 1, A. 4, ad 4: “If a man born among barbarian nations, does what he can, God Himself will show him what is necessary for salvation, either by inspiration or sending a teacher to him.”[cclvii]
St. Thomas Aquinas, Sent. III, 25, Q. 2, A. 2, solute. 2: “If a man should have no one to instruct him, God will show him, unless he culpably wishes to remain where he is.”[cclviii]
The paragraphs below are from here: (8. HOW ALMIGHTY GOD LEADS TO SALVATION THOSE WHO ARE INCULPABLY IGNORANT OF THE TRUTHS OF SALVATION)
Almighty God can also, by a miracle, carry a priest to a person invincibly ignorant and living up to the dictates of his conscience; or he can carry such a person to a priest—or make use of an angel or a saint to lead him to the way of salvation.
Among the holy souls of past centuries who have been loaded with signal favors and privileges by Almighty God, we must place, in the first rank, Mary of Jesus, often styled of Agreda, from the name of the place in Spain where she passed her life. The celebrated J. Goerres, in his grand work, "Mysticism," does not hesitate to cite as an example the life of Mary of Agreda, in a chapter entitled, "The Culminating Point of Christian Mysticism." Indeed, there could not be found a more perfect model of the highest mystic ways.This holy virgin [Ven. Mary of Agreda] burned with a most ardent love for God and for the salvation of souls. One day, she beheld in a vision all the nations of the world. She saw the greater part of men were deprived of God's grace, and running headlong to everlasting perdition. She saw how the Indians of Mexico put fewer obstacles to the grace of conversion than any other nation who were out of the Catholic Church, and how God, on this account, was ready to show mercy to them. Hence she redoubled her prayers and penances to obtain for them the grace of conversion. God heard her prayers. He commanded her to teach the Catholic religion to those Mexican Indians. From that time, she appeared, by way of bilocation, to the savages, not less than five hundred times, instructing them in all the truths of our holy religion, and performing miracles in confirmation of these truths. When all were converted to the faith, she told them that religious priests would be sent by God to receive them into the Church by baptism. As she had told, so it happened. God, in his mercy, sent to these good Indians several Franciscan fathers, who were greatly astonished when they found those savages fully instructed in the Catholic doctrine. When they asked the Indians who had instructed them, they were told that a holy virgin appeared among them many times, and taught them the Catholic religion and confirmed it by miracles. (Life of the Venerable Mary of Jesus of Agreda, § xii.) Thus those good Indians were brought miraculously to the knowledge of the true religion in the Catholic Church, because they followed their conscience in observing the natural law.
Something similar is related in the life of Father J. Anchieta, S. J. (chap. vi.). One day, this great man of God entered the woods of Itannia, in Brazil, without any assignable motive and, in fact, as if he were guided by another. At a little distance he perceived an old man seated on the ground and leaning against a tree. "Hasten your steps," cried the old man when he saw the father, for I have been expecting you for some time." The saintly missionary asked him who he was, and from what country he had come. "My country," said the old man, "is beyond the sea." He added other things, which led the father to infer that he had come from a distant province, near Rio de la Plata, and that he had either been conveyed by supernatural means from his own country to the place where he then was, or that, by the direction and guidance of heaven, he had been led thither with great labor and fatigue, and had placed himself where the father found him, in full expectation of the accomplishment of the divine promise. Father Anchieta then asked him why he had come to that place. "I have come hither," he answered, "in order that I might be taught the right path." This is the expression which the Brazilians use when they speak of the laws of God and of the way to heaven. Father Anchieta felt convinced, from the answers of the old man, that he had never had more than one wife, had never taken up arms except in his own just defense, and that he had never grievously transgressed the law of nature. He perceived, moreover, from the arguments of the old man, that he knew many truths relative to the Author of nature, to the soul, and to virtue and vice. When Father Anchieta had explained to him several of the mysteries of our holy religion, he said: "It is thus that I have hitherto understood them, but I knew not how to define them." After having sufficiently instructed the old man, Father Anchieta collected some rain-water, from the leaves of the wild thistles, baptized him, and named him Adam. The new disciple of Christ immediately experienced in his soul the holy effects of baptism. He raised his eyes and hands to heaven, and thanked Almighty God for the mercy which he had bestowed upon him. Soon after, he expired in the arms of Father Anchieta, who buried him according to the ceremonies of the Church.
About these miraculous conversions Dr. O. A. Brownson well remarks:—
"That there may be persons in heretical and schismatical societies, invincibly ignorant of the Church, who so perfectly correspond to the graces they receive, that Almighty God will, by extraordinary means, bring them to the Church, is believable and perfectly compatible with the known order of his grace, as is evinced by two beautiful examples recorded in Holy Scripture. The one is that of the eunuch of Candice, Queen of Ethiopia: he, following the lights that God gave him, though living at a great distance from Jerusalem, became acquainted with the worship of the true God, and was accustomed to go from time to time to Jerusalem to adore him. When, however, the Gospel began to be published, the Jewish religion could no longer save him; but being well disposed, by fidelity to the graces he had hitherto received, he was not forsaken by Almighty God; for when he was returning to his own country from Jerusalem, the Lord sent a message by an angel to St. Philip to meet and instruct him in the faith of Christ, and baptize him (Acts, viii. 26). The other example is that of Cornelius, who was an officer of the Roman army of the Italic band, and brought up in idolatry. In the course of events, his regiment coming to Judea, he saw there a religion different from his own,—the worship of one only God. Grace moving his heart, he believed in this God, and following the further notion's of divine grace, he gave much alms to the poor, and prayed earnestly to this God to direct him what to do. Did God abandon him? By no means; he sent an angel from heaven to tell him to whom to apply in order to be fully instructed in the knowledge and faith of Jesus Christ, and to be received into his Church by baptism. Now, what God did in these two cases he is no less able to do in all others, and has a thousand ways in his wisdom to conduct souls who are truly in earnest to the knowledge of the truth, and to salvation. And though such a soul were in the remotest wilds of the world, God could send a Philip, or an angel from heaven, to instruct him, or, by the superabundance of his internal grace, or by numberless other ways unknown to us, could infuse into his soul the knowledge of the truth. The great affair is, that we [the non-Catholics] carefully do our part in complying with what he gives us; for of this we are certain, that, if we be not wanting to him, he will never be wanting to us, but, as he begins the good work in us, will also perfect it, if we be careful to correspond and to put no hindrance to his designs.
Their life had only been preserved by God until they could receive baptism and hence be saved:
St. Francis Xavier, May, 1546: "Here (Ambon Island of Indonesia) there are altogether seven towns of Christians, all of which I went through and baptized all the newborn infants and the children not yet baptized. A great many of them died soon after their baptism, so that it was clear enough that their life had only been preserved by God until the entrance to eternal life should be opened to them." Coleridge, Henry. The Life and Letters of St. Francis Xavier. (1872) pg. 375
Fr. De Smet, Dec. 9, 1845: “I have often remarked that many of the children seem to await baptism before winging their flight to heaven, for they die almost immediately after receiving the sacrament.” Laveille, Eugene. The Life of Father de Smet, S. J. (1915) pg. 93 "… over a hundred children and eleven old people were baptized. Many of the latter [the old people], who were carried on buffalo hides, seemed only to await this grace before going to rest in the bosom of God." Laveille, Eugene. The Life of Father de Smet, S. J. (1915) pg. 172
The Life of St. Isaac Jogues, p. 92: "The Huron sorcerers...claimed... the Blackrobes caused people to die by pouring water on their heads; practically everyone they baptized died soon after." Talbot, Francis. Saint Among Savages: The Life of Saint Isaac Jogues
" Among these people was a little child about one year old....It was happily baptized. God preserved its life only by a miracle, it would seem, so that it might be washed in the blood of Jesus Christ and might bless His mercies forever." The Jesuit Relations and Allied Documents, pg. 51 Fr. Lalemant wrote: "...it has happened very often, and has been remarked more than a hundred times, that where we were most welcome, where we baptized most people, there it was in fact where they died the most ; and, on the contrary, in the cabins to which we were denied entrance, although they were sometimes sick to extremity, at the end of a few days one saw every person prosperously cured. We shall see in heaven the secret, but ever adorable, judgments of God therein. Meanwhile, it is one of our most usual astonishments and one of our most solid pleasures, to consider, in the midst of all those things, the gracious bounties of God in the case of those whom he wishes for himself; and to see oftener than every day his sacred and efficacious acts of providence, which so arrange matters that it comes about that not one of the elect is lost, though hell and earth oppose." The Jesuit Relations and Allied Documents, pg. 93