Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow customizing of retry logging handler #77

Open
alexkli opened this issue Mar 14, 2022 · 0 comments
Open

allow customizing of retry logging handler #77

alexkli opened this issue Mar 14, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@alexkli
Copy link
Contributor

alexkli commented Mar 14, 2022

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).

@alexkli alexkli mentioned this issue Apr 23, 2022
@alexkli alexkli changed the title customize logging handler on retry customize retry logging handler Apr 23, 2022
@alexkli alexkli added the enhancement New feature or request label Apr 23, 2022
@alexkli alexkli changed the title customize retry logging handler allow customizing of retry logging handler Apr 26, 2022
@alexkli alexkli added this to the v3 milestone Apr 28, 2022
@alexkli alexkli self-assigned this Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant