Skip to content

Auth error 401 once per day for admin messaging #579

Closed
@trentbrooks

Description

@trentbrooks

Related issues

[REQUIRED] Version info

node: 8

firebase-functions: 7.0.0

firebase-admin: 2.2.0

[REQUIRED] Test case

I run a function every 15 minutes which sends out topic notifications via admin.messaging(), which works extremely well 95% of the time. But just once per day I get authentication error 401 (Unauthorized). It always occurs around the same time 730-930am UTC. I'm using the same global default admin initializeApp().

If there is a way to determine the admin auth status or if a cold start is required, then I might be able to re-intialise before the error?

const functions = require('firebase-functions');

const admin = require('firebase-admin');
admin.initializeApp();

exports.indicatorsUpdated_15m = functions.firestore.document('indicators/15m').onWrite((change, context) => {
    // topic notification code: eg. admin.messaging().sendToTopic()
});


[REQUIRED] Steps to reproduce

Described in test case

[REQUIRED] Expected behavior

No authentication error, and notifications get sent as normal same as other 95% of the day.

[REQUIRED] Actual behavior

Returns auth error, and notifications do not get sent for this one 15 minute window, and it results in a cold restart taking 15-30 seconds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions