Skip to content

perf(cli): cache the Node install layer across source-only changes - #8607

Open
Elior Nataf Lackritz (eliornl) wants to merge 2 commits into
mainfrom
elior/js-dockerfile-layer-order
Open

perf(cli): cache the Node install layer across source-only changes#8607
Elior Nataf Lackritz (eliornl) wants to merge 2 commits into
mainfrom
elior/js-dockerfile-layer-order

Conversation

@eliornl

Copy link
Copy Markdown
Contributor

The generated Node Dockerfile copies source before running the install, so the first source change invalidates the install layer and every dependency is reinstalled. A production build showed 0 / 3 steps cached, with npm ci rebuilding at 16.9s.

Copies package.json and the lockfile first instead.

Falls back to the current output in four cases: no lockfile, an install lifecycle hook present, a custom install command, or a config nested in a workspace. A lockfile is required because without one the install resolves versions at build time, so caching that layer could pin an older resolution than a clean build.

Red/green: 2 of the 10 tests fail on main, the ones asserting the new ordering. The other 8 guard the fallbacks and pass on main by design, so a later change cannot silently widen the optimization. Confirmed the nested-config guard has teeth by deleting it: that test fails and nothing else does.

uv_lock.py changes by one character because _get_node_pm_install_cmd now returns the lockfile alongside the command. Kept as one function since the two facts come from the same directory scan; splitting them means two functions that must agree on package-manager priority.

The generated Node Dockerfile copies source before running the install, so
the first source change invalidates the install layer and every dependency
is reinstalled. A production build showed 0/3 steps cached with `npm ci`
rebuilding at 16.9s.

Copy `package.json` and the lockfile first instead. Falls back to the
current output when there is no lockfile, when an install lifecycle hook is
present, when a custom install command is set, or when the config is nested
in a workspace.

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/cli/langgraph_cli/config.py Outdated
npm runs prepublish, preprepare and postprepare on install too, so a project
using one of those would have had its install layer split and the hook would
run against a source tree that is not there yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant