Skip to content

Feature request: Pass retry count to task queue function #1178

Closed
@gustavopch

Description

@gustavopch

I've tweeted about this and @mbleigh instructed me to file a feature request in the repo, so:

I know that Cloud Tasks sends the HTTP request with a header X-CloudTasks-TaskRetryCount. I need to have that information in the Firebase task queue function so I can handle the last attempt differently, e.g.:

  • Register somewhere that the task was left in a failed state.
  • Send an email to the user informing about the failure and asking to retry manually later.
  • Increase some failure counter.

Maybe consider exposing the raw request just as we can access context.rawRequest in the callable functions.

As @inlined said in this tweet, he is not a fan of exposing the raw request because it would be harder to test. On the other hand, maybe you can expose the retry count as a first-class parameter like context.retryCount, but still expose context.rawRequest as an escape hatch to be used while a first-class parameter doesn't exist. For example, right now I'd be able to use context.rawRequest.headers.get('x-cloudtasks-taskretrycount') until a better parameter is implemented.

If such an escape hatch doesn't exist, people like me either have to wait until the team expose the desired parameter or have to rewrite to use the Cloud Tasks client directly. Using context.rawRequest temporarily would be a much easier workaround even if it's not documented or easy to test.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions