Skip to content

fix(core): improve error handling in nx migrate registry fetching#34926

Merged
leosvelperez merged 1 commit intomasterfrom
core/nx-migrate-hardening
Mar 19, 2026
Merged

fix(core): improve error handling in nx migrate registry fetching#34926
leosvelperez merged 1 commit intomasterfrom
core/nx-migrate-hardening

Conversation

@leosvelperez
Copy link
Member

@leosvelperez leosvelperez commented Mar 19, 2026

Current Behavior

Several issues in nx migrate registry fetching cause confusing errors:

  • packageRegistryPack uses pnpm pack for pnpm users, but pnpm pack only packs the local project (unlike npm pack which downloads remote packages). This silently fails for all pnpm users, always falling back to the slower install path.
  • On Windows, extractFileFromTarball fails because join('package', migrationsFilePath) produces backslash paths that don't match forward-slash tarball entries.
  • When the install fallback also fails, getPackageMigrationsUsingInstall returns {} instead of throwing. The missing version property (undefined) propagates through packageUpdates and collectedVersions, producing Fetching nx@undefined.
  • The install fallback can fail on peer dependency conflicts since legacy-peer-deps was removed as a default (PR fix(misc)!: don't set legacy-peer-deps by default #33014), even though the install only needs files on disk (not a valid dependency tree).
  • The .catch() in fetchMigrations swallows errors without logging, making it impossible to diagnose registry fetch failures.

Expected Behavior

  • packageRegistryPack always uses npm pack since it's the only package manager that supports downloading remote packages
  • Tarball entry matching uses joinPathFragments to normalize paths (forward slashes) for cross-platform compatibility
  • getPackageMigrationsUsingInstall throws on failure with a descriptive error instead of returning an empty object
  • Install fallback sets npm_config_legacy_peer_deps=true since it only needs files on disk, not a valid dependency tree
  • Registry fetch errors are logged at verbose level (NX_VERBOSE_LOGGING=true) for debuggability

Related Issue(s)

Fixes #33135

@leosvelperez leosvelperez requested a review from a team as a code owner March 19, 2026 14:30
@leosvelperez leosvelperez requested a review from AgentEnder March 19, 2026 14:30
@leosvelperez leosvelperez self-assigned this Mar 19, 2026
@netlify
Copy link

netlify bot commented Mar 19, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 17b9c95
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69bc1bbef153870008f07973
😎 Deploy Preview https://deploy-preview-34926--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 19, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 17b9c95
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69bc1bbe8b65130009d0915d
😎 Deploy Preview https://deploy-preview-34926--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Mar 19, 2026

View your CI Pipeline Execution ↗ for commit 17b9c95

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 47m 2s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 9s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-19 16:44:05 UTC

- Always use npm for `pack` since only npm supports downloading remote
  packages (pnpm/yarn/bun pack the local project)
- Throw on install fallback failure instead of returning empty object
  which caused undefined version propagation ("Fetching nx@undefined")
- Log registry fetch errors at verbose level for debuggability
@leosvelperez leosvelperez force-pushed the core/nx-migrate-hardening branch from c13c1dd to 17b9c95 Compare March 19, 2026 15:52
@leosvelperez leosvelperez merged commit b9f251d into master Mar 19, 2026
24 checks passed
@leosvelperez leosvelperez deleted the core/nx-migrate-hardening branch March 19, 2026 16:45
FrozenPandaz pushed a commit that referenced this pull request Mar 20, 2026
…4926)

## Current Behavior

Several issues in `nx migrate` registry fetching cause confusing errors:

- `packageRegistryPack` uses `pnpm pack` for pnpm users, but `pnpm pack`
only packs the local project (unlike `npm pack` which downloads remote
packages). This silently fails for all pnpm users, always falling back
to the slower install path.
- On Windows, `extractFileFromTarball` fails because `join('package',
migrationsFilePath)` produces backslash paths that don't match
forward-slash tarball entries.
- When the install fallback also fails,
`getPackageMigrationsUsingInstall` returns `{}` instead of throwing. The
missing `version` property (`undefined`) propagates through
`packageUpdates` and `collectedVersions`, producing `Fetching
nx@undefined`.
- The install fallback can fail on peer dependency conflicts since
`legacy-peer-deps` was removed as a default (PR #33014), even though the
install only needs files on disk (not a valid dependency tree).
- The `.catch()` in `fetchMigrations` swallows errors without logging,
making it impossible to diagnose registry fetch failures.

## Expected Behavior

- `packageRegistryPack` always uses `npm pack` since it's the only
package manager that supports downloading remote packages
- Tarball entry matching uses `joinPathFragments` to normalize paths
(forward slashes) for cross-platform compatibility
- `getPackageMigrationsUsingInstall` throws on failure with a
descriptive error instead of returning an empty object
- Install fallback sets `npm_config_legacy_peer_deps=true` since it only
needs files on disk, not a valid dependency tree
- Registry fetch errors are logged at verbose level
(`NX_VERBOSE_LOGGING=true`) for debuggability

## Related Issue(s)

Fixes #33135
FrozenPandaz pushed a commit that referenced this pull request Mar 20, 2026
…4926)

## Current Behavior

Several issues in `nx migrate` registry fetching cause confusing errors:

- `packageRegistryPack` uses `pnpm pack` for pnpm users, but `pnpm pack`
only packs the local project (unlike `npm pack` which downloads remote
packages). This silently fails for all pnpm users, always falling back
to the slower install path.
- On Windows, `extractFileFromTarball` fails because `join('package',
migrationsFilePath)` produces backslash paths that don't match
forward-slash tarball entries.
- When the install fallback also fails,
`getPackageMigrationsUsingInstall` returns `{}` instead of throwing. The
missing `version` property (`undefined`) propagates through
`packageUpdates` and `collectedVersions`, producing `Fetching
nx@undefined`.
- The install fallback can fail on peer dependency conflicts since
`legacy-peer-deps` was removed as a default (PR #33014), even though the
install only needs files on disk (not a valid dependency tree).
- The `.catch()` in `fetchMigrations` swallows errors without logging,
making it impossible to diagnose registry fetch failures.

## Expected Behavior

- `packageRegistryPack` always uses `npm pack` since it's the only
package manager that supports downloading remote packages
- Tarball entry matching uses `joinPathFragments` to normalize paths
(forward slashes) for cross-platform compatibility
- `getPackageMigrationsUsingInstall` throws on failure with a
descriptive error instead of returning an empty object
- Install fallback sets `npm_config_legacy_peer_deps=true` since it only
needs files on disk, not a valid dependency tree
- Registry fetch errors are logged at verbose level
(`NX_VERBOSE_LOGGING=true`) for debuggability

## Related Issue(s)

Fixes #33135
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.

nx migrate fails to fetch the expected version

2 participants