-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add logLevel and logRetryAfterSeconds options when initializing the lib #242
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
Conversation
… the lib These are passed down to the underlying HttpExponentialBackoff instance from the @adobe/aio-lib-core-networking dependency
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
pru55e11
left a comment
There was a problem hiding this 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?
There was a problem hiding this 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
logLevelparameter to control logging verbosity for the HttpExponentialBackoff instance - Added
logRetryAfterSecondsparameter (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. | |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
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.
| | [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. | |
| * `__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. |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
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.
| * @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. |
| * @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. |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
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.
| * @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. |
Yes, the spec in package.json is |
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
logRetryAfterSecondsto 0.How Has This Been Tested?
Types of changes
Checklist: