Skip to content

Ignore just-published npm releases in Docker CLI E2E shells - #21615

Merged
Jose Perez Rodriguez (joperezr) merged 2 commits into
mainfrom
aspireagent/fix-js-publish-npm-fresh-release-404
Nov 5, 2026
Merged

Jose Perez Rodriguez (joperezr) merged 2 commits into
mainfrom
aspireagent/fix-js-publish-npm-fresh-release-404

Conversation

@davidfowl

@davidfowl David Fowler (davidfowl) commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes the npm part of the Aspire.Cli.EndToEnd.Tests.JavaScriptPublishTests.AllPublishMethodsBuildDockerImages flake. It is #5 under "Top unowned flakes" in #21600.

Root cause

TypeScript AppHost scaffolds declare floating npm ranges (TypeScriptLanguageSupport.cs: typescript-eslint ^8.57.1, eslint ^10.0.3, nodemon ^3.1.14, …). The Docker E2E shells run npm install with no age limit. If a run installs a few minutes after an upstream publish, npm resolves the new version from the packument while its tarball is still 404. aspire init then fails with npm error code E404, and the test times out waiting for Created apphost.mts or hits an ERR prompt.

Publish times compared with failure times:

Package version (upstream publish) Failing job (E404 on that tarball)
@typescript-eslint/typescript-estree@8.72.1, published 2026-10-26T17:08:21Z 121717304181 at 17:10:58Z (sibling JavaScriptHostingApisRunFromTypeScriptAppHost); 121723096663 at 17:12:51Z
@types/estree@1.0.10, published 2026-10-29T04:34:27Z 123265152317 at 04:38:29Z

All three failures came within 2–5 minutes of the publish, on unrelated branches.

7-day denominator

The job is Cli.EndToEnd-JavaScriptPublishTests (ubuntu-latest). Window: 2026-10-24T20:00Z → 2026-10-31, 751 head SHAs.

  • 849 check runs: 799 success, 22 failure, 28 cancelled. That leaves 821 completed runs.
  • 14 failures are deterministic, not flaky. They are all "Pipeline failed unexpectedly" on a single dependabot npm branch.
  • 8 failures are intermittent (about 1%):
    • 3 are proven npm fresh-release E404s. They are in the table above; this PR fixes them.
    • 2 are aspire init npm installs that stalled without an E404 in the log (122678762903, 124617913801). They have the same symptom, but I can't prove the same cause.
    • 3 are not addressed here. Two are verify-runtime.sh giving up after its 30s budget while aspire run still showed "Preparing Aspire server..." (10-31). One is a 5-minute pipeline timeout.

Fix

PrepareDockerEnvironmentAsync now exports npm_config_before=<now − 1 day>, using npm's before config. The E2E images ship npm 10; min-release-age needs npm ≥ 11.10. With the cutoff:

  • Range resolution in the Docker E2E shells only picks releases that have had time to propagate.
  • Lockfile/pinned installs are unaffected. Dependabot already applies a 7-day cooldown to the E2E npm manifest, so those pins are older than the cutoff.
  • npm view ignores before. For example, RepositoryToolUpdateTests still sees the real latest.

npm pack of an exact version newer than the cutoff fails with ETARGET. The three tests whose subject is acquiring the newest @playwright/cli by exact version therefore opt out with useSettledNpmReleases: false: PlaywrightCliInstallTests ×2 and NewWithAgentInitTests.

No assertions are weakened, and the change adds no sleeps or retries.

Regression test

SettledNpmReleasesTests starts an in-process npm registry that reproduces the post-publish state. 1.1.0 is listed in the packument, published 2 minutes ago, and its tarball returns 404. 1.0.0 is 30 days old and downloadable.

  • Without the cutoff: npm install pkg@^1.0.0 fails with E404 on the 1.1.0 tarball. This is the CI signature, and the test asserts this control case.
  • With GetSettledNpmReleasesCommand(now): the install succeeds with 1.0.0.

Local results:

  • With GetSettledNpmReleasesCommand stubbed to a no-op, the test fails: npm error code E404 … GET http://127.0.0.1:…/aspire-e2e-settle-probe-1.1.0.tgz - Not found.
  • With the fix, it passes on npm 10.9.9 (the E2E image version) and npm 11.20.0.

E2E evidence

The change only affects the CLI E2E Docker shells, so the evidence is CI running real CLI/DCP with the cutoff active:

  • Run 41239786430 on 56c6ec1e: all 131 checks passed and 0 failed.
    • It includes Cli.EndToEnd-JavaScriptPublishTests and every TypeScript/JavaScript CLI E2E class that runs aspire init / npm install.
    • Cli.EndToEnd-SettledNpmReleasesTests ran with 2 succeeded and 0 skipped.
  • Follow-up head 33e39428: only changes the regression test (review feedback). Run 41242524837 passed with 130 checks passing and 0 failing, including Cli.EndToEnd-JavaScriptPublishTests. Cli.EndToEnd-SettledNpmReleasesTests ran with 2 succeeded and 0 skipped.

PlaywrightCliInstallTests and NewWithAgentInitTests are [OuterloopTest], so PR CI doesn't run them. They opt out of the cutoff, which leaves their npm behavior unchanged.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

TypeScript AppHost scaffolds use floating npm ranges, so an E2E run that
installs minutes after an upstream publish can resolve the new version
from registry metadata before its tarball is downloadable and fail with
E404 during 'aspire init' (JavaScriptPublishTests flake, #21600).

Export npm_config_before (now - 1 day) in PrepareDockerEnvironmentAsync so
range resolution picks settled releases. Tests that acquire the newest
@playwright/cli by exact version opt out.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21615

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21615"

@github-actions

This comment has been minimized.

Copilot AI 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.

🟡 Changes recommended

The new E2E test lacks a host npm prerequisite declaration and has a port-allocation race, causing failures when npm is absent or another process claims the port.

2 open issues
What changed in this PR

Reduces npm fresh-release failures in Aspire’s Docker-based CLI E2E tests, addressing part of the flaky-test effort tracked in #21600.

Changes:

  • Applies a one-day npm release cutoff by default in Docker E2E shells.
  • Exempts three scenarios that intentionally acquire the newest Playwright CLI release.
  • Adds a local-registry regression test and a cutoff-formatting test.
File Description
tests/​Aspire.Cli.EndToEnd.Tests/​SettledNpmReleasesTests.cs Tests fresh-release tarball failures and cutoff behavior.
tests/​Aspire.Cli.EndToEnd.Tests/​PlaywrightCliInstallTests.cs Disables the cutoff for two latest-version installation scenarios.
tests/​Aspire.Cli.EndToEnd.Tests/​NewWithAgentInitTests.cs Disables the cutoff for Playwright acquisition during project creation.
tests/​Aspire.Cli.EndToEnd.Tests/​Helpers/​CliE2EAutomatorHelpers.cs Exports the npm cutoff during Docker setup, with an opt-out.

Review effort: Balanced

…site

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

1 / 100 PR test projects · 0 PR jobs, from 4 changed files.

Selected PR test projects (1 / 100)

Aspire.Cli.EndToEnd.Tests

Selected PR jobs (0)

none


How these were chosen — grouped by what changed

🧪 tests/Aspire.Cli.EndToEnd.Tests/Helpers/CliE2EAutomatorHelpers.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/NewWithAgentInitTests.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/PlaywrightCliInstallTests.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/SettledNpmReleasesTests.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

Job reasons

none


Selection computed for commit 33e3942.

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the npm release-cutoff test-infrastructure change.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review October 31, 2026 21:49
@davidfowl David Fowler (davidfowl) added the ci-health Fixes CI flakiness or CI infrastructure (AspireAgent queue) label Nov 1, 2026 — with Copilot SWE Agent
Mitch Denny (mitchdenny) pushed a commit that referenced this pull request Nov 3, 2026
## Description

Fixes a flake in
`Aspire.Cli.EndToEnd.Tests.JavaScriptPublishTests.JavaScriptHostingApisRunFromTypeScriptAppHost`,
tracked in #21600.

The test started the AppHost with `aspire run > aspire-run.log 2>&1 &`
and then immediately ran `verify-runtime.sh`. That script gives each
resource 30 × 1s to write its `ready-port` file and answer HTTP. Because
nothing waited for the AppHost first, the 30s budget also covered
AppHost server preparation and startup. On busy CI runners those
regularly take longer than 30s, so the test failed with `node-npm_FAIL`
while `aspire-run.log` still showed `⚙️ Preparing Aspire server...`.

Changes, all in this one test file:
- Start the AppHost with `aspire start` (via `AspireStartAsync`), which
returns once the AppHost and dashboard are up.
- Run `aspire wait <resource> --status up --timeout 300` for each of
`node-npm`, `javascript-pnpm`, `vite-yarn` and `next-bun`.
- Then run the unchanged endpoint checks in `verify-runtime.sh`. These
still verify that each package manager actually ran the app and that it
serves HTTP.
- Replace the failure diagnostics. They printed `aspire-run.log`, which
no longer exists. They now print `aspire describe <name>` and `aspire
logs <name>`.
- Clean up with `aspire stop` instead of killing a PID.

There are no sleeps, retries or loosened assertions.

The npm/`AllPublishMethodsBuildDockerImages` failures are handled
separately by #21615. That PR lists this failure mode as "not addressed
here". This PR doesn't touch any of the files #21615 changes.

## Evidence

**CI failures** (both on unrelated branches):
- Run
[41207387696](https://github.com/microsoft/aspire/actions/runs/41207387696/job/124557722651)
- Run
[41214363995](https://github.com/microsoft/aspire/actions/runs/41214363995/job/124579017281)

From the terminal recording of the first one:
- `aspire run &` is issued at t=68.08s.
- `verify-runtime.sh` starts at t=68.33s.
- `node-npm_FAIL` appears at t=98.37s, exactly 30s later.
- At that point `aspire-run.log` only contains `⚙️ Preparing Aspire
server...`.

**Local repro with a real TypeScript AppHost.** I used the published
Aspire CLI 13.6.4 with the same `addNodeApp`/`addJavaScriptApp` +
`withNpm({ install: false })` fixtures and the same 30×1s verifier. Two
settings matched CI:
- The AppHost server cache (`.aspire/integrations`) was cleared,
matching the first run in CI.
- The 2-core machine was loaded with 4 busy loops to simulate a busy
runner.

**Before**, using the old flow (`aspire run &`, then verify
immediately). This reproduces the CI signature:
```
t0 aspire run &
node-npm_FAIL
===== tail aspire-run.log =====
⚙️ Preparing Aspire server...
verify exit=1 after 30403ms
```

**After**, using this PR's flow (`aspire start`, then `aspire wait
--status up`, then verify):
```
t0 aspire start
aspire start exit=0 at 52309ms
✅ Resource 'node-npm' is up (running). (0.0s)
✅ Resource 'javascript-npm' is up (running). (0.0s)
node-npm_OK
javascript-npm_OK
RUNTIME_ALL_OK
verify exit=0 at 54832ms
✅ apphost.mts stopped successfully.
```
A cold start took about 52s, well over the old 30s budget. With
readiness gating, the endpoint probes pass within about 0.1s of the
resources reporting up.

**Tests**
- `Aspire.Cli.EndToEnd.Tests` builds cleanly.
- The changed test runs in this PR's CI as the
`Cli.EndToEnd-JavaScriptPublishTests` job.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] Yes
  - [ ] No
- Did you add public API?
  - [ ] Yes
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@radical

Copy link
Copy Markdown
Member

[automated] Starting natural paired Docker CLI E2E validation of this test-only change: 25 pre-fix and 50 post-fix fresh Ubuntu runners initially, one JavaScriptPublishTests class invocation per runner. If the original signature does not reproduce, cumulative sampling may increase to 250 provisioned runners per arm. Historical npm release windows and other failure causes will be reported separately; passing samples will not be treated as proof of zero flakiness.

Mitch Denny (mitchdenny) pushed a commit that referenced this pull request Nov 5, 2026
…21634)

## Description

Fixes the npm fresh-release E404 part of the `Polyglot SDK Validation`
TypeScript flake tracked in #21600.

### Root cause

TypeScript AppHost scaffolds and fixtures declare floating npm ranges.
The TypeScript validation container runs `npm install` without a
release-age limit. If a run installs a few minutes after an upstream
publish, npm picks the new version from the packument while its tarball
still returns 404. `aspire init --language typescript` then fails with
`npm error code E404` / `❌ The app could not be created.`

In the last 7 days this caused 5 failed jobs across 3 unrelated branches
(details in #21633). Each failure came 2–4 minutes after the upstream
publish of `@typescript-eslint/typescript-estree@8.72.1` or
`@types/estree@1.0.10`. These are the same publishes #21615 fixes for
the CLI E2E Docker shells, but that PR doesn't cover this container.

### Fix

The `Run TypeScript SDK validation` step now passes
`npm_config_before=<now − 1 day>` into the container ([npm `before`
config](https://docs.npmjs.com/cli/v11/using-npm/config#before)). This
matches #21615. npm range resolution in `aspire init`, the fixture
installs, the JavaScript app installer and the Nuxt fixture only selects
releases that have had time to propagate. The global tool installs at
image build time are unaffected. pnpm, Yarn and Bun don't read this
setting. No retries, sleeps or skips are added.

### Validation

- **Mock registry with npm 11.19.0 (the image's npm):** the packument
lists `1.1.0` (published 2 minutes ago, tarball 404) and `1.0.0` (30
days old).
- Without the cutoff, `npm install pkg@^1.0.0` fails with `npm error
code E404`, the CI signature.
  - With the cutoff, it installs `1.0.0`.
- **Real registry with npm 11.19.0 and the cutoff:**
  - The TypeScript scaffold's dependency set installs.
- `playground/NuxtApp/web` installs, with 596 packages including
`nuxt@4.5.2`.
- All 58 npm-managed `tests/PolyglotAppHosts/*/TypeScript` and
integration playground `package.json` files resolve. No ETARGET.
  - The pnpm fixture resolves.
- **`actionlint`:** passes on `polyglot-validation.yml`.

Other intermittent TypeScript validation failures from the same window
have different causes and are not addressed here: the Nuxt dev-mode
health wait timing out (3), `bun install` `ConnectionRefused` (2), and
an MCR pull failure (1).

Fixes #21633

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [ ] Yes
- [x] No (CI workflow configuration only; validated as described above)
- Did you add public API?
  - [ ] Yes
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [ ] Yes
  - [x] No

**🤖 Posted by AspireAgent (AI Agent)**

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The one-day npm cutoff stabilizes external dependency inputs without changing the scaffold, publish, endpoint, or success assertions. Tests whose purpose is newest-release acquisition explicitly opt out. The tradeoff is delayed coverage of ordinary dependencies published within the last day, not relaxed application expectations. Additional paired-validation results can be considered separately for merge readiness.

@joperezr
Jose Perez Rodriguez (joperezr) merged commit eecbe87 into main Nov 5, 2026
166 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 5, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_optional → test_only. No signals triggered (signal_count == 0). All 4 changed files match tests/Aspire.Cli.EndToEnd.Tests/**; only the E2E test shell setup changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-cli ci-health Fixes CI flakiness or CI infrastructure (AspireAgent queue)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants