I have a daily scheduled function as follows:
export const dailyExecutedFunction = async (): Promise<void> => {
try {
// some other code
setRoutineAnalytics();
} catch (error) {
functions.logger.error(error);
functions.logger.error(
'Something went wrong with daily executed function',
{ structuredData: true }
);
}
};
And the setRoutineAnalytics
function:
export async function setRoutineAnalytics(): Promise<void> {
try {
functions.logger.info('A');
const date = getDateFromDaysAgo(1);
const dailyRoutines = await firestore
.collection('today_routines')
.where('date', '==', date)
.get(); // around 300 - 400 docs
functions.logger.info('B');
// update routine analytics with some other code
} catch (error) {
functions.logger.error(error);
functions.logger.error(
'Something went wrong with setting routine analytics',
{ structuredData: true }
);
}
}
I have verified that setRoutineAnalytics
works fine when I call it manually using a http cloud function (functions.https.onRequest
). However, when it doesn’t work when called by a scheduled function (functions.pubsub
).
Inspecting the logs explorer, ‘A’ gets logged but ‘B’ does not. There are also no error messages that are logged.
What could be the issue here?