Commit c8496b8
fix(core): improve error handling in nx migrate registry fetching (#34926)
## 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 #331351 parent 1d0c889 commit c8496b8
File tree
2 files changed
+21
-20
lines changed- packages/nx/src
- command-line/migrate
- utils
2 files changed
+21
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
978 | 979 | | |
979 | 980 | | |
980 | 981 | | |
981 | | - | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
982 | 986 | | |
983 | 987 | | |
984 | 988 | | |
| |||
1115 | 1119 | | |
1116 | 1120 | | |
1117 | 1121 | | |
1118 | | - | |
| 1122 | + | |
1119 | 1123 | | |
1120 | 1124 | | |
1121 | 1125 | | |
| |||
1148 | 1152 | | |
1149 | 1153 | | |
1150 | 1154 | | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
1151 | 1159 | | |
1152 | 1160 | | |
1153 | 1161 | | |
| |||
1163 | 1171 | | |
1164 | 1172 | | |
1165 | 1173 | | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
1171 | 1177 | | |
1172 | 1178 | | |
1173 | 1179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
626 | 621 | | |
627 | 622 | | |
628 | 623 | | |
| |||
0 commit comments