Skip to content

Retry VS Code unit-test yarn install on dnceng npm 429 - #21657

Merged
David Fowler (davidfowl) merged 1 commit into
mainfrom
aspireagent/retry-extension-unit-yarn-install
Nov 4, 2026
Merged

David Fowler (davidfowl) merged 1 commit into
mainfrom
aspireagent/retry-extension-unit-yarn-install

Conversation

@davidfowl

Copy link
Copy Markdown
Collaborator

Description

Run VS Code extension unit tests (Windows) intermittently fails at Install dependencies when the dnceng npm feed returns 429 Too Many Requests. Yarn 1.22 retries only 408 and 5xx responses (request-manager.js), so a single 429 fails the job.

This PR gives that step the same bounded install retry that extension-e2e-tests.yml already uses: 3 attempts with 30s and 60s backoff. It applies only to package installation. Run tests is not retried, and no assertions change.

Fixes #18691

Evidence

Window: ci.yml attempt-1, 2026-10-25T13:15Z → 2026-11-01T13:23Z (840 runs). I scanned all 2,242 failed jobs (logs plus check-run annotations).

  • 5 failed jobs contain Request failed "429 Too Many Requests" from pkgs.dev.azure.com/dnceng/.../dotnet-public-npm.
  • 3 were in Run VS Code extension unit tests (Windows), all at Install dependencies. That lane had 315 decided jobs (main 62, PR 313) and 12 failures. Failing step lines:
    ##[group]Run corepack yarn install --frozen-lockfile --non-interactive
    yarn install v1.22.22
    error Error: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/normalize-url/-/normalize-url-8.1.1.tgz: Request failed "429 Too Many Requests"
    
    Jobs: 121749755178 (10-26), 122300050910 (10-27), 123668457045 (10-29).
  • 1 was in Validate VS Code extension bootstrap (Linux), which deliberately validates a cold Corepack cache. This PR leaves it unchanged.
  • 1 was in the E2E matrix (job 122971943509, 10-28). The existing retry recovered it: attempt 1 got 429, it logged Retrying in 30s (attempt 2 of 3), and attempt 2 finished with Done in 6.76s. That job failed later, at the test step, for an unrelated reason.

Validation

I extracted the exact run: script from the workflow and ran it under pwsh 7.4.6 with GitHub's pwsh wrapper ($ErrorActionPreference = 'stop' plus the trailing exit $LASTEXITCODE). A native stub corepack printed the real 429 line for the first N calls. Start-Sleep was stubbed to record the requested delays.

429 responses Before (single install) After
0 exit 0 exit 0, 1 call
1 exit 1 exit 0, 2 calls, backoff 30s
2 exit 1 exit 0, 3 calls, backoff 30s and 60s
3 exit 1 exit 1, 3 calls, failed after 3 attempts

On this PR, CI runs the Windows unit-test job with the new step. A 429 can't be forced in CI, so the recovery path is shown by the local run above and by the E2E job's existing retry log.

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. This is a CI workflow change only; it was validated with the harness above.
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No

🤖 Posted by AspireAgent (AI Agent)

The dnceng npm feed intermittently returns 429 Too Many Requests and Yarn 1
only retries 408/5xx. Mirror the bounded install retry that
extension-e2e-tests.yml already uses so a single rate-limit response does not
fail the Windows unit-test job. Tests themselves are not retried.

Fixes #18691

Co-authored-by: Copilot <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 2026

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 -- 21657

Or

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

@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot November 1, 2026 13:33
@github-actions github-actions Bot added the area-engineering-systems infrastructure helix infra engineering repo stuff label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Tests selector

1 / 100 PR test projects · 1 PR job, from 1 changed file.

Selected PR test projects (1 / 100)

Infrastructure.Tests

Selected PR jobs (1)

extension-unit


How these were chosen — grouped by what changed

📄 .github/workflows/extension-unit-tests.yml (changed)
→ 1 directly: Infrastructure.Tests

Job reasons

Job Triggered by
extension-unit .github/workflows/extension-unit-tests.yml

Selection computed for commit 8caf959.

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 change adding bounded dependency-install retries to the Windows extension unit-test workflow.

No open issues 🎉

What changed in this PR

This PR reduces intermittent failures in Aspire’s Windows VS Code extension unit-test workflow caused by dnceng npm feed rate limiting, addressing #18691.

Changes:

  • Retries dependency installation up to three times, with 30-second and 60-second delays.
  • Logs retry attempts and fails the step after retries are exhausted.
  • Leaves test execution unchanged; tests are not retried.
File Description
.github/​workflows/​extension-unit-tests.yml Adds bounded retries around Yarn dependency installation, matching the existing extension E2E workflow approach.

Review effort: Balanced

@davidfowl
David Fowler (davidfowl) marked this pull request as ready for review November 1, 2026 14:00
@davidfowl David Fowler (davidfowl) added the ci-health Fixes CI flakiness or CI infrastructure (AspireAgent queue) label Nov 1, 2026 — with Copilot SWE Agent
Ankit Jain (radical) pushed a commit that referenced this pull request Nov 4, 2026
…file directories (#21660)

## Description

Fixes #21659

Dependabot `npm_and_yarn` security-update PRs write internal dnceng
`resolved` URLs into lockfiles that must use the public npm registry.
Over the last 7 days, 4 of 5 such PRs failed CI on attempt 1, with 7–18
jobs failed per run:
- `TemplatePackageLockTests.*_UsesPublicNpmRegistry` on every OS
- Starter Validation
- Docker `npm ci` E401 in the K8s TypeScript, PV and JavaScriptPublish
E2E tests

**Root cause:** if a package directory has no `.npmrc`, Dependabot walks
up the parent directories to find one (dependabot-core
`npm_and_yarn/file_fetcher.rb#npmrc` →
`fetch_file_from_parent_directories`). It therefore uses the repo-root
`.npmrc`, whose `registry=` is the dnceng feed. Local npm stops at the
package root, so locally regenerated lockfiles stay on npmjs. Only
Dependabot drifts.

**Fix:**
- Add a directory `.npmrc` with `registry=https://registry.npmjs.org/`
to the 8 lockfile directories that must use the public registry:
- `ts-starter`, `ts-starter/frontend`, `py-starter`,
`py-starter/frontend`, `java-starter/frontend`
  - `aspire-ts-cs-starter/frontend`
  - `JsPublish/nextjs`, `JsPublish/npmscript`

  Dependabot reads the directory's own `.npmrc` first.
- Don't ship these repo-only files to customers, so a user's own
registry config isn't overridden:
- `Aspire.Cli.csproj`: `EmbeddedResource
Remove="Templating\Templates\**\.npmrc"`
- `Aspire.ProjectTemplates.csproj`: `TemplateFiles` excludes
`templates\**\.npmrc`
- Repo-internal lockfiles that are meant to use dnceng are unchanged.

**Selective CI:** a new `test-trigger-map.yml` path rule routes the
JsPublish fixture `.npmrc` files to `test:Aspire.Cli.Tests`. The
selector regression
`TestTriggerMapTests.JsPublishFixtureNpmrcRunsCliPublicRegistryGuard`
covers it: it fails with the rule reverted, and all 346 TestTriggerMap
tests pass.

**Regression tests** in `TemplatePackageLockTests`:
-
`PublicRegistryPackageLockDirectory_PinsPublicNpmRegistryForDependabot`
(8 cases)
- `CliTemplateResources_DoNotIncludeRepoOnlyNpmrc`

## Evidence

**Before and after lockfile resolution.** This mirrors Dependabot's
update on #21404: `npm install [email protected] --package-lock-only` on the
ts-starter frontend from `main`.

| `.npmrc` Dependabot sees | `resolved` hosts | vite 8.3.5 resolved |
|---|---|---|
| repo root (before) | 159 `registry.npmjs.org` + **17
`pkgs.dev.azure.com`** | `pkgs.dev.azure.com/dnceng/.../vite-8.3.5.tgz`
|
| directory `.npmrc` (after) | **177 `registry.npmjs.org`** |
`registry.npmjs.org/vite/-/vite-8.3.5.tgz` |

The "before" split is the same as the actual Dependabot commit on #21404
(17 dnceng URLs in this file).

**Docker `npm ci`** (`node:22-alpine`, no credentials, `npm ci
--ignore-scripts`):
- Before lockfile: `npm error code E401 Unable to authenticate, your
authentication token seems to be invalid` (exit 1). This matches CI.
- After lockfile: `added 152 packages in 4s` (exit 0).

**Tests and packaging:**
- `TemplatePackageLockTests`: 33/33 pass locally.
- With `ts-starter/frontend/.npmrc` removed, the new test fails as
expected.
- `dotnet msbuild Aspire.ProjectTemplates.csproj
-getItem:TemplateFiles`: 303 items, 0 `.npmrc`, and the frontend
`package-lock.json` is still included.

**Out of scope:** the TypeScript SDK unit-test E401 comes from a
lockfile that is meant to use dnceng and asks for versions the feed
hasn't cached yet. dnceng 429 retries are covered by #18691 / #21657.

## 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 <[email protected]>
Co-authored-by: Copilot <[email protected]>
@davidfowl
David Fowler (davidfowl) merged commit f51026c into main Nov 4, 2026
60 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Nov 4, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

docs_optional → build_or_ci_only (proven false positive). Triggered signal: pr_body_has_cli_flag_mention (evidence: PR body log snippet yarn install --frozen-lockfile --non-interactive). The only changed file is .github/workflows/extension-unit-tests.yml, which matches .github/**; no user-facing change.

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

Labels

area-engineering-systems infrastructure helix infra engineering repo stuff ci-health Fixes CI flakiness or CI infrastructure (AspireAgent queue)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI Failure] NPM registry rate limiting (HTTP 429 Too Many Requests) from dnceng feed

2 participants