Skip to content

allow customizing of retry logging handlerΒ #77

@alexkli

Description

@alexkli

Current Behaviour

Currently node-fetch-retry will console.log or console.error on retry (and other cases), with a specific message. For example here.

Inventory of console.*:

on retry:

on init (config read):

Issue

Apps using node-fetch-try might want a different log message or use a different logging.

For example, they might want to log error details from a specific header or the response body. Currently it only prints the response.statusText in case of a non-success HTTP response.

Apps should be in control and be able to have node-fetch-retry not call console.* at all.

Proposal

Add the option for a custom function onRetry in the retryOptions that would be used instead of the current logging. Signature might follow the usual pattern

function onRetry(response, error) {
   // response if response was returned otherwise null
   // error if an error was thrown
}

Note sure how to handle the "on init" case, maybe another onInitLog function. Or use the npm debug library (which is off by default).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions