Can't mogodb insert inside a promise chain using meteor
<p>Need help with a roadblock.</p>

<p>I am using a promise based npm package to fetch charity data. The package is promise based so I am using a promise chain to parse and fetch the data. All this works well. I am able to create a soap client, search for the data, fetch the data, parse the data into an array of objects ready for writing to mongo db, but it's this last step that is the problem. </p>

<p>If I write one sample object to the db within the final .then() it get stuck/halts and does not even return an error. I can write to the db before the start of the promise chain but not inside. I prefer to use native Promises and not any external library. What am I missing here?</p>

<pre><code>// dummy data
const test = {
    CharityName: 'test'
};

Meteor.startup(function() {
    // init the db here.
    console.log(`Meteor started`);
    console.log(Charities.find().count());

    // *1 Charities.insert(test);

    if (Charities.find().count() === 0) {
        console.log('dbs is empty');
        ccAPI.createClient(ccAPIUrl)
            .then(function(client) {

                // *2 Charities.insert(test);

                console.log('searching for charitites');
                return GetCharitiesByKeywordList(client, { APIKey }, ["searchTerm"]);
        })
        .then(function(obj) {
            console.log('fetching all charities');
            const { client, res } = obj;
            return fetchAllCharities(client, { APIKey }, res);
        })
        .then(function(val) {
            console.log(`parse returned data with makeData()`);
            return makeData(val);
        })
        .then(function(val) {
            console.log(`writing objects to db`);

            // *3 Charities.insert(test);

        })
        .catch(function(error) {
            throw error;
        });
}
});
</code></pre>

<p>*1 works but  *2 &amp;  *3 seems to hang the progress the code. The details of the library calls do not matter what is important here is that I cannot write to the db from within the promise chain.</p>