I've got some code that works fine running locally, tested using Supertest, but when the same test runs on CircleCI it fails due to time-outs.
The code in question is
for (const id of ids) {
const urls = await scrapeLinks(id) // invokes puppeteer on a dockerised mock server
await connectUrls(fbId, urls) // updates database using sequelize
}
Running locally this works fine.
Running the same tests on CircleCI this code takes too long to complete and the test times out.
But if I add a couple of console.log lines, then the tests do not time out
for (const id of ids) {
console.log('start', id)
const urls = await scrapeLinks(id) // invokes puppeteer on a dockerised mock server
console.log('urls', urls)
await connectUrls(fbId, urls) // updates database using sequelize
console.log('end', id)
}
Running the tests on that works fine both locally, and on CircleCI.
My simple fix was of course simply to extend the timeout on my tests from 2 seconds to 5 seconds.
But my question is, why does the addition of console.log lines after each step make the code complete more quickly?