-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat(core): add env var for cache size #31609
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
base: master
Are you sure you want to change the base?
feat(core): add env var for cache size #31609
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
View your CI Pipeline Execution ↗ for commit 746a132.
☁️ Nx Cloud last updated this comment at |
@@ -71,13 +71,14 @@ export function getCache(options: DefaultTasksRunnerOptions): DbCache | Cache { | |||
|
|||
export class DbCache { | |||
private nxJson = readNxJson(); | |||
private rawMaxCacheSize = process.env.NX_MAX_CACHE_SIZE ?? this.nxJson.maxCacheSize; |
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.
@claude can you please extract this logic into a reusable logic which is used in report.ts
as well?
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.
Claude finished @FrozenPandaz's task —— View job
✅ Extracted NX_MAX_CACHE_SIZE Logic
I've successfully extracted the duplicated logic for handling NX_MAX_CACHE_SIZE into a reusable utility as requested.
Todo List:
- Read current implementation in both
cache.ts
andreport.ts
- Identify the duplicated logic that needs extraction
- Create a reusable utility function
- Update both files to use the utility
- Test the changes
- Commit the refactored code
Analysis:
Found duplicated logic in both files:
cache.ts:74
andcache.ts:80-82
: Environment variable resolution and cache size parsingreport.ts:306-310
: Same logic for resolving max cache size
Changes Made:
- Created
resolveMaxCacheSize(nxJson)
utility function incache.ts:608-613
- Updated
DbCache
class to use the new utility instead of duplicated logic - Updated
report.ts
to import and use the new utility function - Removed unused imports from
report.ts
(getDefaultMaxCacheSize, cacheDir) - TypeScript compilation passes ✅
- Files formatted with Prettier ✅
- Committed changes with descriptive message ✅
The refactoring consolidates the logic for resolving max cache size from environment variables or nx.json configuration into a single, reusable function that both files now use.
| NX_MAX_CACHE_SIZE | string | Overrides the `maxCacheSize` option in `nx.json` and defines the maximum size of the local task cache. Accepts the same units as the config option. | ||
| |
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 table formatting for the NX_MAX_CACHE_SIZE
entry is broken. The description text should be contained within a single row, ending with a pipe character. Please fix it to:
| NX_MAX_CACHE_SIZE | string | Overrides the `maxCacheSize` option in `nx.json` and defines the maximum size of the local task cache. Accepts the same units as the config option. |
This will maintain proper table structure and ensure the documentation renders correctly.
| NX_MAX_CACHE_SIZE | string | Overrides the `maxCacheSize` option in `nx.json` and defines the maximum size of the local task cache. Accepts the same units as the config option. | |
| | |
| NX_MAX_CACHE_SIZE | string | Overrides the `maxCacheSize` option in `nx.json` and defines the maximum size of the local task cache. Accepts the same units as the config option. | |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
@claude please fix the formatting issues. |
Claude finished @FrozenPandaz's task —— View job ✅ Fixed Formatting IssuesI've successfully fixed the formatting issues in this PR. Todo List
Changes MadeFixed table formatting in
Committed: The formatting fix has been committed to the PR branch (commit The CI format check should now pass ✅ |
151f3de
to
a3f72d3
Compare
@@ -37,6 +37,7 @@ The following environment variables are ones that you can set to change the beha | |||
| NX_SKIP_LOG_GROUPING | boolean | If set to `true`, Nx will not group command's logs on CI. | | |||
| NX_MIGRATE_CLI_VERSION | string | The version of Nx to use for running the `nx migrate` command. If not set, it defaults to `latest`. | | |||
| NX_LOAD_DOT_ENV_FILES | boolean | If set to 'false', Nx will not load any environment files (e.g. `.local.env`, `.env.local`) | | |||
| NX_MAX_CACHE_SIZE | string | Overrides the `maxCacheSize` option in `nx.json` and defines the maximum size of the local task cache. Accepts the same units as the config option. | |
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.
@claude Can you update this documentation better please?
It should not be documented as an override but rather an alternative.
It should point to the max cache size setting which should have accurate information about how this should be set.
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.
Claude finished @FrozenPandaz's task —— View job
✅ Updated NX_MAX_CACHE_SIZE Documentation
I've successfully improved the documentation for NX_MAX_CACHE_SIZE as requested.
Todo List
- Read current environment variables documentation
- Read nx.json documentation for max cache size setting
- Update NX_MAX_CACHE_SIZE documentation to be clearer
- Commit the documentation improvements
- Update comment with completion status
Changes Made
Updated docs/shared/reference/environment-variables.md
:
- Changed "Overrides the
maxCacheSize
option innx.json
" to "Alternative to configuringmaxCacheSize
innx.json
" - Added proper reference link to the detailed
maxCacheSize
documentation - Made it clear this is an alternative configuration method rather than an override
- Maintained the essential information about cache size configuration
New Documentation Text
| NX_MAX_CACHE_SIZE | string | Alternative to configuring `maxCacheSize` in `nx.json`. Defines the maximum size of the local task cache. See [`maxCacheSize`](/reference/nx-json#max-cache-size) for supported units and behavior details. |
Committed: The documentation improvement has been committed (commit cac8c4c
).
The documentation now better reflects that NX_MAX_CACHE_SIZE is an alternative configuration method and points users to the comprehensive maxCacheSize documentation for detailed information about units and behavior.
@claude can you fix whatever is failing? |
Claude finished @FrozenPandaz's task —— View job ✅ Fixed Formatting IssuesI've successfully resolved the failing CI issues in this PR. Todo List
What Was FixedPrimary Issue - Format Check Failure: The main CI failure was due to a lexer error in Solution Applied:
Results✅ Format check now passes - The main CI failure has been resolved The CI should now pass the format check that was previously failing. The other validation issues mentioned in the prepush output (commit message format check for older commits and documentation generation) are related to existing commits in the PR and don't prevent the formatting fix from working correctly. |
….json setting docs: improve NX_MAX_CACHE_SIZE documentation - Describe it as an alternative to nx.json config rather than an override - Reference the detailed maxCacheSize documentation in nx.json - Provide proper link to max cache size section Co-authored-by: Jason Jean <FrozenPandaz@users.noreply.github.com>
a5d4613
to
746a132
Compare
Summary
nx report
NX_MAX_CACHE_SIZE
optionTesting
pnpm nx run-many -t lint,test,build
(failed: NX Lexer error)pnpm test:e2e
(failed: Command "test:e2e" not found)pnpm e2e
(failed: Failed to process project graph)https://chatgpt.com/codex/tasks/task_e_68503bff022c832c8c014c61432aa2ed