Skip to content

fix(lib): retry the staging install without --prefer-offline outside CI - #407

Open
jsteinich wants to merge 1 commit into
open-constructs:mainfrom
jsteinich:claude/pack-prefer-offline-retry
Open

fix(lib): retry the staging install without --prefer-offline outside CI#407
jsteinich wants to merge 1 commit into
open-constructs:mainfrom
jsteinich:claude/pack-prefer-offline-retry

Conversation

@jsteinich

Copy link
Copy Markdown
Contributor

Related issue

No issue — follow-up from #395, where this cost real time during the upgrade.

Description

packages/cdktn/scripts/pack.mjs installs the staging dependencies with --prefer-offline. When the local npm cache holds a packument older than a dependency bump, npm never refreshes it and reports:

npm error code ETARGET
npm error notarget No matching version found for jsii-pacmak@1.140.0.

The version does exist — the cached index just predates it. The message blames the pin, so the natural reaction is to distrust the version rather than the cache. This happened repeatedly while upgrading jsii, on a long-lived container with a warm cache.

Outside CI the install is retried once with --prefer-online, which refreshes the metadata and succeeds.

In CI the error is rethrown untouched. A release build that cannot resolve a pinned version should fail rather than quietly reach for a different resolution — the fallback exists to unstick local development, not to paper over a non-reproducible build. process.env.CI is set by GitHub Actions.

Verification

The happy path is unchanged (warm cache, single install, no retry).

The gate was exercised by pinning a dependency to a version that does not exist, which produces the real ETARGET:

CI unset   retry fired once, then failed
CI=true    no retry, failed immediately

Checklist

  • I have updated the PR title to match CDKTN's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

🤖 Generated with Claude Code

`scripts/pack.mjs` installs staging deps with --prefer-offline. When the
local npm cache holds a packument older than a dependency bump, npm never
refreshes it and reports ETARGET -- "No matching version found" -- for a
version that does exist. The message blames the version, so the usual
reaction is to distrust the pin rather than the cache.

Outside CI we now retry once with --prefer-online. In CI the failure is
rethrown untouched, so a stale cache can never quietly change what gets
packaged; a release build that cannot resolve a pinned version should
fail rather than silently reach for a different resolution.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@jsteinich
jsteinich requested a review from a team as a code owner September 9, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant