Skip to content

Implement request-safe assessment cache with TTL and tests - #6

Merged
nicolasgioanni merged 2 commits into
mainfrom
develop
Jul 28, 2026
Merged

Implement request-safe assessment cache with TTL and tests#6
nicolasgioanni merged 2 commits into
mainfrom
develop

Conversation

@nicolasgioanni

Copy link
Copy Markdown
Collaborator

This pull request refactors the assessment configuration caching logic in gohighlevel-assessment.ts to avoid sharing in-flight asynchronous discovery operations between parallel requests. It also adds new tests to ensure that assessment configuration discovery is not shared and that failed discoveries are retried correctly. The changes improve cache safety, correctness, and test coverage.

Assessment Configuration Caching Improvements

  • Refactored the assessment configuration cache to store the resolved AssessmentConfiguration object directly instead of a promise, ensuring that parallel calls do not share in-flight discovery operations. Now, each call to getAssessmentConfiguration will independently trigger discovery if the cache is expired or empty, preventing accidental sharing of incomplete or failed discoveries.
  • Updated the test cache reset function to clear the new assessmentConfiguration variable instead of the removed promise.

Test Coverage Enhancements

  • Added a test to verify that in-flight assessment configuration discovery is not shared between parallel requests, ensuring that each request independently fetches configuration as needed. (Fb7f17b9L1040R1040)
  • Added a test to confirm that the system retries assessment configuration discovery after a failed attempt, by simulating a failure and ensuring a subsequent successful discovery is possible. (Fb7f17b9L1040R1040)
  • Improved an existing test to suppress error logs for cleaner test output.

- Replaced the module-level discovery promise with a plain resolved assessment configuration cache.

- Added a 15-minute TTL gate that only returns cached configuration when it is still valid.

- Updated cache initialization to avoid storing in-flight discovery promises and prevent cross-request context errors.
- Added a regression test that verifies sequential submissions reuse warmed assessment configuration.

- Added a regression test for concurrent cold-cache calls that independently discover and do not share an in-flight request promise.

- Added a regression test that verifies failed discovery is not cached and is retried on the next request.
@nicolasgioanni nicolasgioanni self-assigned this Jul 28, 2026

@nicolasgioanni nicolasgioanni left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fix implemented

@nicolasgioanni
nicolasgioanni merged commit b3836f5 into main Jul 28, 2026
1 of 2 checks passed
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.

1 participant