Skip to content

Conversation

@shazron
Copy link
Member

@shazron shazron commented Nov 13, 2025

These are passed down to the underlying HttpExponentialBackoff instance from the @adobe/aio-lib-core-networking dependency

See https://jira.corp.adobe.com/browse/ACNA-4162
Dependent on adobe/aio-lib-core-networking#102

Motivation and Context

Users were getting timeouts when calling the State service. This is not a State service availability or timeout issue, it is because the user's call is throttled by a 429 and a Retry-After header is sent. Often because of overuse, the throttle amount will be 60 seconds which is above the timeout amount for an action run.

This retry behavior not evident in the logs unless the log level was set to debug. This will automatically log the retry attempt if the value is above a certain threshold, in this case, the default value of 10 seconds.

This does not fix the issue, but brings it to the light. To turn off this default behavior, users can explicitly set the init option of logRetryAfterSeconds to 0.

How Has This Been Tested?

  • unit tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

… the lib

These are passed down to the underlying HttpExponentialBackoff instance from the @adobe/aio-lib-core-networking dependency
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@shazron shazron changed the title feat: add logLevel and logRetryAfterSeconds options when initializing… feat: add logLevel and logRetryAfterSeconds options when initializing the lib Nov 13, 2025
@shazron shazron marked this pull request as ready for review November 13, 2025 09:59
Copy link
Contributor

@pru55e11 pru55e11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming there's no need to update package.json for the updated networking lib in the other PR?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds two new optional configuration parameters (logLevel and logRetryAfterSeconds) to the state library initialization that are passed to the underlying HttpExponentialBackoff instance from @adobe/aio-lib-core-networking. This helps address user timeout issues caused by 429 throttling responses by making retry behavior more visible in logs when retry-after values exceed a configurable threshold (defaulting to 10 seconds).

  • Added logLevel parameter to control logging verbosity for the HttpExponentialBackoff instance
  • Added logRetryAfterSeconds parameter (defaults to 10) to automatically log retry attempts when Retry-After header values exceed the threshold
  • Updated type definitions, implementation, tests, and documentation to support these new options

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
types.d.ts Added type definitions for the new logLevel (string) and logRetryAfterSeconds (number) optional parameters in the init function signature
lib/init.js Added constant for default retry logging threshold, extracted new parameters from config, and passed them to AdobeState.init
lib/AdobeState.js Updated constructor and static init method to accept and pass the new parameters to HttpExponentialBackoff
test/init.test.js Added comprehensive test coverage for the new parameters including individual and combined usage scenarios
doc/api.md Updated API documentation to describe the new configuration parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

| [config.ow] | [<code>OpenWhiskCredentials</code>](#OpenWhiskCredentials) | [OpenWhiskCredentials](#OpenWhiskCredentials). Set those if you want to use ootb credentials to access the state management service. OpenWhisk namespace and auth can also be passed through environment variables: `__OW_NAMESPACE` and `__OW_API_KEY` |
| [config.region] | <code>string</code> | optional region to use, accepted values: `amer` (default), `emea`, `apac` |
| [config.logLevel] | <code>string</code> | optional log level for the HttpExponentialBackoff instance |
| [config.logRetryAfterSeconds] | <code>number</code> | Defaults to 10. if the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable. |
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The capitalization of "if" should be "If" to maintain consistency with standard sentence capitalization in documentation.

Suggested change
| [config.logRetryAfterSeconds] | <code>number</code> | Defaults to 10. if the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable. |
| [config.logRetryAfterSeconds] | <code>number</code> | Defaults to 10. If the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable. |

Copilot uses AI. Check for mistakes.
* `__OW_NAMESPACE` and `__OW_API_KEY`
* @param {string} [config.region] optional region to use, accepted values: `amer` (default), `emea`, `apac`
* @param {string} [config.logLevel] optional log level for the HttpExponentialBackoff instance
* @param {number} [config.logRetryAfterSeconds] Defaults to 10. if the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable.
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The capitalization of "if" should be "If" to maintain consistency with standard sentence capitalization in documentation.

Suggested change
* @param {number} [config.logRetryAfterSeconds] Defaults to 10. if the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable.
* @param {number} [config.logRetryAfterSeconds] Defaults to 10. If the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable.

Copilot uses AI. Check for mistakes.
* @param {string} env the Adobe environment (AIO_CLI_ENV)
* @param {('amer'|'apac'|'emea')} [region] the region for the Adobe State Store. defaults to 'amer'
* @param {string} [logLevel] the log level for the HttpExponentialBackoff instance
* @param {number} [logRetryAfterSeconds] if the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable.
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The capitalization of "if" should be "If" to maintain consistency with standard sentence capitalization in documentation.

Suggested change
* @param {number} [logRetryAfterSeconds] if the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable.
* @param {number} [logRetryAfterSeconds] If the request has to retry because of a 429, it will log the retry attempt as a warning if the Retry-After value is greater than this number. Set to 0 to disable.

Copilot uses AI. Check for mistakes.
@shazron shazron merged commit 8da6526 into main Nov 17, 2025
15 checks passed
@shazron
Copy link
Member Author

shazron commented Nov 17, 2025

I'm assuming there's no need to update package.json for the updated networking lib in the other PR?

Yes, the spec in package.json is ^5 so it should pick up the minor update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants