Closed emelski closed 2 years ago
Don't forget to update the README and the typescript definitions file.
Don't forget to update the README and the typescript definitions file.
Thanks for the reminder, I added updates to those files.
@logdnabot test this
@logdnabot test this
Closing this PR, superseded by PR59.
Allow users to optionally specify a maximum number of attempts to send in case of retryable errors, instead of retrying indefinitely.
The logger will accept an integer "maxAttempts" option, which gives the total number of attempts (including the first) when retryable errors are encountered.
When the limit is reached, errors that would otherwise be considered retryable are instead treated as non-retryable.
If "maxAttempts" is negative (or not specified), the logger will continue to retry indefinitely.
lib/logger.js: Add definitions and initialization for maxAttempts. Add convenience method _shouldRetry() to determine whether or not to retry given a specific error code.
lib/constants.js: Add MAX_ATTEMPTS default value.
test/logger-errors.js: Add a test to verify that retries are limited.
test/logger-instantiation.js: Add a test for maxAttempts option validation.
test/common/create-options.js: Update test support code.