Fix TestUpdateNPMInstall timing out on a cold npm cache - #485
Open
joe4dev wants to merge 1 commit into
Open
Conversation
joe4dev
force-pushed
the
devx-1108-npm-install-test-timeout
branch
2 times, most recently
from
September 4, 2026 11:56
e1a696e to
eb9ebbd
Compare
Co-Authored-By: Claude <noreply@anthropic.com>
joe4dev
force-pushed
the
devx-1108-npm-install-test-timeout
branch
from
September 4, 2026 12:03
eb9ebbd to
f6a3d4f
Compare
joe4dev
commented
Sep 4, 2026
| // grandchild to finish and write its success summary into the still-open | ||
| // pipe, and the failure reads "exit status 1" beside output claiming the | ||
| // install succeeded. | ||
| ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) |
Member
Author
There was a problem hiding this comment.
main change: increasing timeout from 2 min to 5 min
joe4dev
commented
Sep 4, 2026
| // deadline leaves the node grandchild holding the output pipe, and | ||
| // CombinedOutput would block for that grandchild's full lifetime (the | ||
| // DEVX-846 lesson). | ||
| npmInstall := exec.CommandContext(ctx, "npm", "install", "--no-audit", "--no-fund", "@localstack/lstk") |
Member
Author
There was a problem hiding this comment.
supporting change: skipping audit and fund is recommended in CI https://www.lowlydba.com/cicd-npm-flags/
joe4dev
marked this pull request as ready for review
September 4, 2026 12:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
TestUpdateNPMInstallis failing onmain, on both the Windows and the ubuntu runners. The two report it very differently, which is what made it look like a registry problem.Windows — npm claims success, process exits 1:
Ubuntu — the smoking gun, killed at exactly the deadline with no output:
It is a timeout, not an npm error. The test runs on the shared
testContext(t)— 2 minutes — and nearly all of that goes into thenpm installfrom the registry, a cost set by the registry rather than by the test.How long it takes when it passes (
windows-latest, last six greenmainruns):So normally 19-81s — but on a slow day the install alone stretches past two minutes (one failing run's npm reported
in 3m), and the 2-minute budget turns that into a red build. Ubuntu's120.01sduration is exactly the context deadline, which is the clearest confirmation available.The Windows signature is misleading for a specific reason:
npmthere is a.cmdwrapper aroundnode, soexec.CommandContextkills the wrapper while thenodegrandchild keeps going, finishes, and writes its success summary into the still-open pipe. On Linuxnpmis a real exec, so the kill surfaces honestly assignal: killed.Solution
testContext, following the existing precedent insam_e2e_test.goandlicense_test.go(both opt out with a comment for the same class of reason). That is ~3.7x the slowest observed passing run and still clears the ~3m slow-registry outlier, so the budget stops being the thing that fails without letting a genuinely hung install sit for ages.--no-audit --no-fundon the local install — small next to the download, but free.cmd.WaitDelayon both npm-spawning execs, so a deadline kill can't leaveCombinedOutputblocked on a grandchild holding the pipe (the DEVX-846 lesson, already documented in CLAUDE.md).ctx.Err()in both failure messages, so the next timeout says "context deadline exceeded" instead of impersonating an npm failure. This is what made the original diagnosis slow.Test-only change; no production code touched.
Manual testing
The test skips when
lstkis onPATH(npm install -gwould collide), and forcing it to run installs@localstack/lstkglobally, so I did not run it end to end locally. Sizing came from the CI durations above instead. Locally I timed the individual phases in throwaway dirs (global install into a temp--prefix) to confirm which one dominates:The last line is the useful one: the
npm install -ginsidelstk updateis not a second slow install, it reuses the cache the first one filled. Only one phase is expensive.CI on this PR is the real verification — the
Integration Tests (windows-latest)andIntegration Tests (ubuntu-latest)jobs, both of which fail onmaintoday.Docs
Nothing to document — test-infrastructure only. No user-facing command, flag, env var, or behavior changes.
Review
Human review advised — the diagnosis is worth a second pair of eyes even though the change is test-only, since the 5-minute budget is a judgement call.
Closes DEVX-1108