pnpm 12.8.0 → 12.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,97 @@
1
1
  # pnpm
2
2
 
3
+ ## 12.8.2
4
+
5
+ pnpm 12.8.2 fixes a startup crash on Linux ppc64le and `UnknownIssuer` errors on systems without CA certificates. `pnpm run` no longer installs before every script on CI when `autoDedupe` is enabled, and resolution and hoisted installs on macOS are faster.
6
+
7
+ ### Patch Changes
8
+
9
+ #### Platforms and environments
10
+
11
+ - Fixed pnpm crashing on startup on Linux ppc64le [#16380](https://github.com/pnpm/pnpm/issues/16380).
12
+
13
+ - Fixed installs failing with `UnknownIssuer` on Linux systems without CA certificates, such as `node:24-slim`, when `NODE_EXTRA_CA_CERTS` is set. The extra certificates now extend the bundled CA roots [#16365](https://github.com/pnpm/pnpm/issues/16365).
14
+
15
+ - pnpm now creates its store operation locks and other per-user lock files in `$XDG_RUNTIME_DIR` when it points to a directory only the user can write to. Otherwise, pnpm still uses `/tmp` on Linux and macOS. Sandboxes that block writes to `/tmp` can point `XDG_RUNTIME_DIR` at a writable directory [#16390](https://github.com/pnpm/pnpm/issues/16390).
16
+
17
+ - POSIX bin shims and the `pnpm`, `pn`, `pnpx`, and `pnx` launchers now run inside a Nix build, where the system default path holds none of the utilities they call. Installing again replaces the shims already in `node_modules` [#16377](https://github.com/pnpm/pnpm/issues/16377).
18
+
19
+ - In a project that pins another pnpm version, pnpm now passes a command with an option it does not know to the pinned version. Before, pnpm rejected the option before switching, so `pnpm install --auto-dedupe` failed with "Unknown option" even though the pinned pnpm supports it [#16353](https://github.com/pnpm/pnpm/issues/16353).
20
+
21
+ #### Installing and resolving dependencies
22
+
23
+ - `pnpm install --frozen-lockfile` now fails when `Cargo.lock` does not satisfy a dependency requirement in `Cargo.toml`. The error names the crate and the version the lockfile holds [#16355](https://github.com/pnpm/pnpm/issues/16355).
24
+
25
+ - `pnpm install` returns "Already up to date" again in a workspace with injected workspace dependencies and a shared lockfile. Since 12.7.0 every repeat install in such a workspace ran the full install and copied the injected projects again.
26
+
27
+ - With `injectWorkspacePackages: true`, a fresh `pnpm install` now records a workspace dependency as `link:` when its injected copy differs from the project only by an optional peer that peer-dependent dedupe merges. It was recorded as a peer-suffixed `file:` copy [#16354](https://github.com/pnpm/pnpm/issues/16354).
28
+
29
+ - `pnpm dedupe --check` now passes right after `pnpm dedupe` when deduplication merges variants of a package that differ only in their peers. A lockfile key whose peer suffix named a merged variant now names the variant that replaced it [#16356](https://github.com/pnpm/pnpm/issues/16356).
30
+
31
+ - When `minimumReleaseAge` hides the version that `latest` points to, pnpm now falls back to a prerelease of the same major before a stable version of an older major. A stable version of the same major is still preferred. Before, while a new `1.0.0` was too new, `latest` fell back to an old `0.0.1` even though `1.0.0-beta.4` had been `latest` until then [#16388](https://github.com/pnpm/pnpm/issues/16388).
32
+
33
+ - Git-hosted dependencies now respect `pmOnFail`. If it is set to anything other than `download`, a git-hosted dependency that pins a pnpm version is prepared by the running pnpm, and pnpm does not download the pinned version [#16376](https://github.com/pnpm/pnpm/issues/16376).
34
+
35
+ - pnpmfile hooks such as `readPackage` now run once for a dependency that several packages request at the same time. They could run twice for it before.
36
+
37
+ - `childConcurrency` now defaults to 5, the documented value. It used to be capped at 4 and to follow the host's CPU count.
38
+
39
+ #### Running scripts
40
+
41
+ - `pnpm run` and `pnpm exec` no longer install dependencies before every script on CI when `autoDedupe` is enabled. `pnpm install --frozen-lockfile` now keeps the deduplication record left by an earlier install [#16374](https://github.com/pnpm/pnpm/issues/16374).
42
+
43
+ - On macOS and Linux, lifecycle scripts and `pnpm run` now always get `PATH` from the `PATH` variable. When the environment also held a `Path` variable, a script sometimes got `Path`'s value, and failed with `node: not found` [#16308](https://github.com/pnpm/pnpm/issues/16308).
44
+
45
+ - `pnpm run` now exits after a `SIGTERM` in a container where pnpm is PID 1 and the script runs pnpm again, as `"start": "pnpm serve"` does. Since 12.6.0 it kept waiting after the script had shut down, until the container runtime killed it.
46
+
47
+ #### Other commands and settings
48
+
49
+ - `pnpm config get globalShims`, `pnpm shim list`, and global installs no longer read `globalShims` from a project's `pnpm-workspace.yaml`. Only the global config file, the pnpm home's own `pnpm-workspace.yaml`, and `PNPM_CONFIG_GLOBAL_SHIMS` set it, so a repository cannot choose which globally installed packages get project-aware shims.
50
+
51
+ - `pnpm config set --location=project` refuses a machine-level setting such as `stateDir` or `scope` with `ERR_PNPM_CONFIG_SET_NOT_A_PROJECT_SETTING`, which names where the setting belongs. `pnpm config delete` still clears such a key from a project's `pnpm-workspace.yaml`.
52
+
53
+ - `pnpm deploy` no longer fails with `ERR_PNPM_DEPLOY_AMBIGUOUS_PEER` in a workspace with `injectWorkspacePackages: true` when a workspace package lists its peer dependency as a dev dependency too [#16375](https://github.com/pnpm/pnpm/issues/16375).
54
+
55
+ - `pnpm deploy` no longer copies the workspace root's `packageManager` and `devEngines.packageManager` fields into the deployed `package.json` [#16403](https://github.com/pnpm/pnpm/issues/16403).
56
+
57
+ - `pnpm publish` now includes bare `README` files and README files with Markdown extensions such as `readme.markdown` in registry metadata [#12704](https://github.com/pnpm/pnpm/issues/12704).
58
+
59
+ - `pnpm store prune` now removes the packages that only expired `pnpm dlx` cache entries used. They were left in the store until the next `pnpm store prune` [#16383](https://github.com/pnpm/pnpm/discussions/16383).
60
+
61
+ #### Performance
62
+
63
+ - Sped up dependency resolution in large workspaces, and when many dependencies request different ranges of the same package. Resolution also uses less memory.
64
+
65
+ - Sped up `pnpm install` with `nodeLinker: hoisted` on macOS when the lockfile is re-resolved, such as with `autoDedupe` enabled [#16397](https://github.com/pnpm/pnpm/issues/16397).
66
+
67
+ - Sped up extracting package tarballs.
68
+
69
+ - `pnpm install` without `--frozen-lockfile` is faster on some machines in projects with a `pnpm-workspace.yaml`. Those installs linked with one worker thread per core, half of what a frozen install uses.
70
+
71
+ - On Windows, warm `pnpm install --frozen-lockfile` runs are 4-5% faster on 4- and 8-core machines. pnpm now links with one worker thread per core on Windows, between 4 and 16. This changes frozen installs and installs in projects without a `pnpm-workspace.yaml` on machines with 3 to 15 cores.
72
+
73
+ ## 12.8.1
74
+
75
+ pnpm 12.8.1 fixes `pnpm install --frozen-lockfile` rejecting lockfiles with injected workspace packages that have peers, restores the executable bit on files of local directory dependencies, makes `pnpm dedupe` converge, and uses less CPU on many-core machines.
76
+
77
+ ### Patch Changes
78
+
79
+ - `pnpm install --frozen-lockfile` no longer rejects a freshly generated lockfile when an injected workspace package has peer dependencies [#16332](https://github.com/pnpm/pnpm/issues/16332).
80
+
81
+ - Executable files in a `file:` directory dependency or an injected workspace package keep their executable bit again. Since 12.8.0, pnpm installed these files without the permissions they have in their project.
82
+
83
+ - `pnpm dedupe` now reaches a stable lockfile when a package's peer suffix is long enough to be hashed. Before, each run could switch that package's key between the hashed and the spelled-out suffix, so `pnpm dedupe --check` always failed [#16331](https://github.com/pnpm/pnpm/issues/16331).
84
+
85
+ - `pnpm install --frozen-lockfile`, the default in CI, now uses less CPU on machines with more than 8 cores. Warm installs on many-core Windows machines got up to 10% faster. Frozen installs now link with at most 16 worker threads.
86
+
87
+ - `verifyDepsBeforeRun` no longer reports dependencies as outdated after a filtered install just because `pnpm-lock.yaml` has a newer modification time. It checks the lockfile against the packages that install put in place. Before, `pnpm run` reinstalled the whole workspace with lifecycle scripts on, for example after a Docker `COPY` brought in a lockfile with a newer mtime [#16322](https://github.com/pnpm/pnpm/issues/16322).
88
+
89
+ After a filtered install, `verifyDepsBeforeRun` now also checks that the install put the selected projects' dependencies in place. A `node_modules` directory alone no longer counts as proof.
90
+
91
+ - `pnpm run` and `pnpm exec` no longer install a project that has never been installed and has nothing to install. Such a project declares no dependencies, no peer dependencies that `autoInstallPeers` would fetch, and no install lifecycle scripts. The command now runs without writing `node_modules` or `pnpm-lock.yaml` [#16313](https://github.com/pnpm/pnpm/issues/16313).
92
+
93
+ - `pnpm update -g --latest` now upgrades globally installed packages beyond their saved version ranges [#16320](https://github.com/pnpm/pnpm/issues/16320).
94
+
3
95
  ## 12.8.0
4
96
 
5
97
  pnpm 12.8.0 warns when `pnpm pack` or `pnpm publish` would ship a `.env` file that `files` does not list, installs `sharedWorkspaceLockfile: false` workspaces concurrently, applies every setting passed as `--config.<name>=<value>`, and no longer leaves the Windows terminal stuck after Ctrl+C in a script.
@@ -43,6 +43,8 @@ while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
43
43
  done
44
44
  basedir=$(command -p printf '%s\n' "$link" | command -p sed -e 's,\\,/,g')
45
45
  basedir="${basedir%/*}"
46
+ basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
47
+ basedir="$basedir_abs"
46
48
  basedir_win="$basedir"
47
49
  exe=""
48
50
  msys=""
@@ -73,11 +75,12 @@ case `command -p uname -a` in
73
75
  esac
74
76
  if [ -n "$caller_path_set" ]; then PATH=$caller_path; else unset PATH; fi
75
77
 
76
- basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
77
78
  if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
78
79
  exec "$basedir/node.exe" "$basedir_win/../get-pnpm/bin/get-pnpm.js" "$@"
79
80
  elif [ -x "$basedir/node" ]; then
80
81
  exec "$basedir/node" "$basedir_abs/../get-pnpm/bin/get-pnpm.js" "$@"
82
+ elif [ -n "$msys" ] && command -v node >/dev/null 2>&1; then
83
+ exec node "$basedir_win/../get-pnpm/bin/get-pnpm.js" "$@"
81
84
  elif command -v node >/dev/null 2>&1; then
82
85
  exec node "$basedir_abs/../get-pnpm/bin/get-pnpm.js" "$@"
83
86
  elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
@@ -43,6 +43,8 @@ while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
43
43
  done
44
44
  basedir=$(command -p printf '%s\n' "$link" | command -p sed -e 's,\\,/,g')
45
45
  basedir="${basedir%/*}"
46
+ basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
47
+ basedir="$basedir_abs"
46
48
  basedir_win="$basedir"
47
49
  exe=""
48
50
  msys=""
@@ -73,11 +75,12 @@ case `command -p uname -a` in
73
75
  esac
74
76
  if [ -n "$caller_path_set" ]; then PATH=$caller_path; else unset PATH; fi
75
77
 
76
- basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
77
78
  if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
78
79
  exec "$basedir/node.exe" "$basedir_win/../node-gyp/bin/node-gyp.js" "$@"
79
80
  elif [ -x "$basedir/node" ]; then
80
81
  exec "$basedir/node" "$basedir_abs/../node-gyp/bin/node-gyp.js" "$@"
82
+ elif [ -n "$msys" ] && command -v node >/dev/null 2>&1; then
83
+ exec node "$basedir_win/../node-gyp/bin/node-gyp.js" "$@"
81
84
  elif command -v node >/dev/null 2>&1; then
82
85
  exec node "$basedir_abs/../node-gyp/bin/node-gyp.js" "$@"
83
86
  elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
@@ -43,6 +43,8 @@ while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
43
43
  done
44
44
  basedir=$(command -p printf '%s\n' "$link" | command -p sed -e 's,\\,/,g')
45
45
  basedir="${basedir%/*}"
46
+ basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
47
+ basedir="$basedir_abs"
46
48
  basedir_win="$basedir"
47
49
  exe=""
48
50
  msys=""
@@ -73,11 +75,12 @@ case `command -p uname -a` in
73
75
  esac
74
76
  if [ -n "$caller_path_set" ]; then PATH=$caller_path; else unset PATH; fi
75
77
 
76
- basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
77
78
  if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
78
79
  exec "$basedir/node.exe" "$basedir_win/../which/bin/which.js" "$@"
79
80
  elif [ -x "$basedir/node" ]; then
80
81
  exec "$basedir/node" "$basedir_abs/../which/bin/which.js" "$@"
82
+ elif [ -n "$msys" ] && command -v node >/dev/null 2>&1; then
83
+ exec node "$basedir_win/../which/bin/which.js" "$@"
81
84
  elif command -v node >/dev/null 2>&1; then
82
85
  exec node "$basedir_abs/../which/bin/which.js" "$@"
83
86
  elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
@@ -43,6 +43,8 @@ while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
43
43
  done
44
44
  basedir=$(command -p printf '%s\n' "$link" | command -p sed -e 's,\\,/,g')
45
45
  basedir="${basedir%/*}"
46
+ basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
47
+ basedir="$basedir_abs"
46
48
  basedir_win="$basedir"
47
49
  exe=""
48
50
  msys=""
@@ -73,11 +75,12 @@ case `command -p uname -a` in
73
75
  esac
74
76
  if [ -n "$caller_path_set" ]; then PATH=$caller_path; else unset PATH; fi
75
77
 
76
- basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
77
78
  if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
78
79
  exec "$basedir/node.exe" "$basedir_win/../nopt/bin/nopt.js" "$@"
79
80
  elif [ -x "$basedir/node" ]; then
80
81
  exec "$basedir/node" "$basedir_abs/../nopt/bin/nopt.js" "$@"
82
+ elif [ -n "$msys" ] && command -v node >/dev/null 2>&1; then
83
+ exec node "$basedir_win/../nopt/bin/nopt.js" "$@"
81
84
  elif command -v node >/dev/null 2>&1; then
82
85
  exec node "$basedir_abs/../nopt/bin/nopt.js" "$@"
83
86
  elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
@@ -43,6 +43,8 @@ while [ -L "$link" ] && [ "$hops" -lt 40 ]; do
43
43
  done
44
44
  basedir=$(command -p printf '%s\n' "$link" | command -p sed -e 's,\\,/,g')
45
45
  basedir="${basedir%/*}"
46
+ basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
47
+ basedir="$basedir_abs"
46
48
  basedir_win="$basedir"
47
49
  exe=""
48
50
  msys=""
@@ -73,11 +75,12 @@ case `command -p uname -a` in
73
75
  esac
74
76
  if [ -n "$caller_path_set" ]; then PATH=$caller_path; else unset PATH; fi
75
77
 
76
- basedir_abs=$(CDPATH= cd -P -- "$basedir" && pwd -P) || exit $?
77
78
  if [ -n "$exe" ] && [ -x "$basedir/node.exe" ]; then
78
79
  exec "$basedir/node.exe" "$basedir_win/../semver/bin/semver.js" "$@"
79
80
  elif [ -x "$basedir/node" ]; then
80
81
  exec "$basedir/node" "$basedir_abs/../semver/bin/semver.js" "$@"
82
+ elif [ -n "$msys" ] && command -v node >/dev/null 2>&1; then
83
+ exec node "$basedir_win/../semver/bin/semver.js" "$@"
81
84
  elif command -v node >/dev/null 2>&1; then
82
85
  exec node "$basedir_abs/../semver/bin/semver.js" "$@"
83
86
  elif [ -n "$exe" ] && command -v node.exe >/dev/null 2>&1; then
@@ -1,9 +1,10 @@
1
1
  {
2
- "lastValidatedTimestamp": 1790578965103,
2
+ "lastValidatedTimestamp": 1790728888790,
3
3
  "projects": {
4
4
  "/home/runner/_work/pnpm/pnpm/pnpm/npm/pnpm/temp-deploy": {
5
5
  "name": "pacquet",
6
- "version": "12.8.0"
6
+ "version": "12.8.2",
7
+ "hasModulesDir": true
7
8
  }
8
9
  },
9
10
  "pnpmfiles": [],
@@ -87,6 +88,7 @@
87
88
  "@types/zkochan__table": "npm:@types/table@6.3.2",
88
89
  "@typescript-eslint/utils": "^8.70.1",
89
90
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
91
+ "@webcontainer/api": "^1.6.4",
90
92
  "@yarnpkg/core": "4.9.1",
91
93
  "@yarnpkg/extensions": "2.0.7",
92
94
  "@yarnpkg/fslib": "^3.1.5",
@@ -112,7 +114,7 @@
112
114
  "camelcase-keys": "^10.0.3",
113
115
  "can-link": "^3.0.0",
114
116
  "can-write-to-dir": "^2.0.0",
115
- "chalk": "^6.0.0",
117
+ "chalk": "^6.0.1",
116
118
  "ci-info": "^4.4.0",
117
119
  "cli-truncate": "^6.1.1",
118
120
  "cmd-extension": "^2.0.0",
@@ -133,7 +135,7 @@
133
135
  "eslint": "^10.11.0",
134
136
  "eslint-plugin-import-x": "^4.17.1",
135
137
  "eslint-plugin-jest": "^29.16.6",
136
- "eslint-plugin-n": "^18.3.0",
138
+ "eslint-plugin-n": "^18.4.0",
137
139
  "eslint-plugin-promise": "^7.3.0",
138
140
  "eslint-plugin-regexp": "^3.1.1",
139
141
  "eslint-plugin-simple-import-sort": "^14.0.0",
@@ -149,8 +151,8 @@
149
151
  "graceful-fs": "^4.2.11",
150
152
  "graph-cycles": "3.0.0",
151
153
  "hosted-git-info": "npm:@pnpm/hosted-git-info@1.0.0",
152
- "http-proxy-agent": "^7.0.2",
153
- "https-proxy-agent": "^7.0.6",
154
+ "http-proxy-agent": "^9.1.0",
155
+ "https-proxy-agent": "^9.1.0",
154
156
  "https-proxy-server-express": "0.1.2",
155
157
  "human-id": "^4.2.1",
156
158
  "husky": "^9.1.7",
@@ -158,7 +160,7 @@
158
160
  "ini": "6.0.0",
159
161
  "is-gzip": "2.0.0",
160
162
  "is-inner-link": "^5.0.0",
161
- "is-subdir": "^2.0.0",
163
+ "is-subdir": "^2.0.1",
162
164
  "is-windows": "^1.0.2",
163
165
  "isexe": "4.0.0",
164
166
  "jest": "30.4.2",
@@ -189,7 +191,7 @@
189
191
  "npm-registry-fetch": "^19.0.0",
190
192
  "object-hash": "3.0.0",
191
193
  "open": "^11.0.4",
192
- "openpgp": "^6.3.1",
194
+ "openpgp": "^6.3.2",
193
195
  "p-defer": "^4.0.1",
194
196
  "p-every": "^2.0.0",
195
197
  "p-filter": "^4.1.0",
@@ -202,8 +204,9 @@
202
204
  "path-name": "^1.0.0",
203
205
  "path-temp": "^3.0.0",
204
206
  "pidtree": "^1.0.0",
207
+ "playwright-core": "^1.63.0",
205
208
  "preferred-pm": "^5.0.1",
206
- "pretty-bytes": "^7.1.3",
209
+ "pretty-bytes": "^7.2.0",
207
210
  "pretty-ms": "^9.3.1",
208
211
  "promise-share": "^2.0.1",
209
212
  "proxy": "^4.1.0",
@@ -233,7 +236,7 @@
233
236
  "shx": "^0.4.0",
234
237
  "signal-exit": "^4.1.0",
235
238
  "socks": "^2.8.10",
236
- "socks-proxy-agent": "^8.0.5",
239
+ "socks-proxy-agent": "^10.1.0",
237
240
  "sort-keys": "^6.0.1",
238
241
  "spdx-expression-parse": "5.0.0",
239
242
  "split-cmd": "^1.1.0",
@@ -241,7 +244,7 @@
241
244
  "ssri": "13.0.1",
242
245
  "stacktracey": "^2.2.0",
243
246
  "string-length": "^7.0.1",
244
- "string-width": "^8.2.2",
247
+ "string-width": "^8.3.0",
245
248
  "strip-bom": "^5.0.0",
246
249
  "strip-comments-strings": "1.2.0",
247
250
  "symlink-dir": "^10.0.3",
@@ -256,7 +259,7 @@
256
259
  "typescript": "6.0.3",
257
260
  "typescript-eslint": "^8.70.1",
258
261
  "uid-number": "0.0.6",
259
- "undici": "^7.29.0",
262
+ "undici": "^7.29.1",
260
263
  "unified": "^11.0.5",
261
264
  "validate-npm-package-name": "7.0.2",
262
265
  "version-selector-type": "^3.0.0",
@@ -263,11 +263,77 @@ class Request {
263
263
  }
264
264
  }
265
265
 
266
- onUpgrade (statusCode, headers, socket) {
266
+ /**
267
+ * @param {number|null} statusCode
268
+ * @param {Buffer[]|null} headers
269
+ * @param {import('node:stream').Duplex} socket
270
+ * @param {string} [statusText]
271
+ */
272
+ onUpgrade (statusCode, headers, socket, statusText = '') {
273
+ this.onFinally()
274
+
267
275
  assert(!this.aborted)
268
276
  assert(!this.completed)
269
277
 
270
- return this[kHandler].onUpgrade(statusCode, headers, socket)
278
+ if (statusCode !== null) {
279
+ this.#publishUpgradeHeaders(statusCode, headers, statusText)
280
+ }
281
+
282
+ const result = this[kHandler].onUpgrade(statusCode, headers, socket)
283
+
284
+ if (!this.aborted) {
285
+ this.completed = true
286
+ if (statusCode !== null) {
287
+ this.#publishUpgradeTrailers()
288
+ }
289
+ }
290
+
291
+ return result
292
+ }
293
+
294
+ /**
295
+ * @param {number} statusCode
296
+ * @param {import('node:http2').IncomingHttpHeaders} headers
297
+ * @param {(headers: import('node:http2').IncomingHttpHeaders) => Buffer[]} parseHeaders
298
+ * @param {string} [statusText]
299
+ */
300
+ onUpgradeResponse (statusCode, headers, parseHeaders, statusText = '') {
301
+ assert(!this.aborted)
302
+ assert(this.completed)
303
+
304
+ if (channels.headers.hasSubscribers) {
305
+ this.#publishUpgradeHeaders(statusCode, parseHeaders(headers), statusText)
306
+ }
307
+ this.#publishUpgradeTrailers()
308
+ }
309
+
310
+ /**
311
+ * @param {Error} error
312
+ */
313
+ onUpgradeError (error) {
314
+ assert(!this.aborted)
315
+ assert(this.completed)
316
+
317
+ if (channels.error.hasSubscribers) {
318
+ channels.error.publish({ request: this, error })
319
+ }
320
+ }
321
+
322
+ /**
323
+ * @param {number} statusCode
324
+ * @param {Buffer[]} headers
325
+ * @param {string} statusText
326
+ */
327
+ #publishUpgradeHeaders (statusCode, headers, statusText) {
328
+ if (channels.headers.hasSubscribers) {
329
+ channels.headers.publish({ request: this, response: { statusCode, headers, statusText } })
330
+ }
331
+ }
332
+
333
+ #publishUpgradeTrailers () {
334
+ if (channels.trailers.hasSubscribers) {
335
+ channels.trailers.publish({ request: this, trailers: [] })
336
+ }
271
337
  }
272
338
 
273
339
  onComplete (trailers) {
@@ -432,7 +432,7 @@ class Parser {
432
432
  }
433
433
 
434
434
  onUpgrade (head) {
435
- const { upgrade, client, socket, headers, statusCode } = this
435
+ const { upgrade, client, socket, headers, statusCode, statusText } = this
436
436
 
437
437
  assert(upgrade)
438
438
  assert(client[kSocket] === socket)
@@ -467,9 +467,10 @@ class Parser {
467
467
  client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade'))
468
468
 
469
469
  try {
470
- request.onUpgrade(statusCode, headers, socket)
471
- } catch (err) {
472
- util.destroy(socket, err)
470
+ request.onUpgrade(statusCode, headers, socket, statusText)
471
+ } catch (error) {
472
+ util.errorRequest(client, request, error)
473
+ util.destroy(socket, error)
473
474
  }
474
475
 
475
476
  client[kResume]()
@@ -1050,12 +1051,22 @@ function writeH1 (client, request) {
1050
1051
  const socket = client[kSocket]
1051
1052
  clearIdleSocketValidation(socket)
1052
1053
 
1053
- const abort = (err) => {
1054
- if (request.aborted || request.completed) {
1054
+ /**
1055
+ * @param {Error} [error]
1056
+ */
1057
+ const abort = (error) => {
1058
+ if (request.aborted) {
1059
+ return
1060
+ }
1061
+
1062
+ if (request.completed) {
1063
+ if (request.upgrade || request.method === 'CONNECT') {
1064
+ util.destroy(socket, new InformationalError('aborted'))
1065
+ }
1055
1066
  return
1056
1067
  }
1057
1068
 
1058
- util.errorRequest(client, request, err || new RequestAbortedError())
1069
+ util.errorRequest(client, request, error || new RequestAbortedError())
1059
1070
 
1060
1071
  util.destroy(body)
1061
1072
  util.destroy(socket, new InformationalError('aborted'))
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const assert = require('node:assert')
4
+ const { errorMonitor } = require('node:events')
4
5
  const { pipeline } = require('node:stream')
5
6
  const util = require('../core/util.js')
6
7
  const {
@@ -77,6 +78,15 @@ function parseH2Headers (headers) {
77
78
  return result
78
79
  }
79
80
 
81
+ /**
82
+ * @param {import('node:http2').IncomingHttpHeaders} headers
83
+ * @returns {Buffer[]}
84
+ */
85
+ function parseH2ResponseHeaders (headers) {
86
+ const { [HTTP2_HEADER_STATUS]: _statusCode, ...realHeaders } = headers
87
+ return parseH2Headers(realHeaders)
88
+ }
89
+
80
90
  async function connectH2 (client, socket) {
81
91
  client[kSocket] = socket
82
92
 
@@ -297,22 +307,32 @@ function writeH2 (client, request) {
297
307
  headers[HTTP2_HEADER_AUTHORITY] = host || `${hostname}${port ? `:${port}` : ''}`
298
308
  headers[HTTP2_HEADER_METHOD] = method
299
309
 
300
- const abort = (err) => {
301
- if (request.aborted || request.completed) {
310
+ /**
311
+ * @param {Error} [error]
312
+ */
313
+ const abort = (error) => {
314
+ if (request.aborted) {
315
+ return
316
+ }
317
+
318
+ if (request.completed) {
319
+ if (method === 'CONNECT' && stream != null) {
320
+ util.destroy(stream, error || new RequestAbortedError())
321
+ }
302
322
  return
303
323
  }
304
324
 
305
- err = err || new RequestAbortedError()
325
+ error = error || new RequestAbortedError()
306
326
 
307
- util.errorRequest(client, request, err)
327
+ util.errorRequest(client, request, error)
308
328
 
309
329
  if (stream != null) {
310
- util.destroy(stream, err)
330
+ util.destroy(stream, error)
311
331
  }
312
332
 
313
333
  // We do not destroy the socket as we can continue using the session
314
334
  // the stream get's destroyed and the session remains to create new streams
315
- util.destroy(body, err)
335
+ util.destroy(body, error)
316
336
  client[kQueue][client[kRunningIdx]++] = null
317
337
  client[kResume]()
318
338
  }
@@ -331,25 +351,57 @@ function writeH2 (client, request) {
331
351
 
332
352
  if (method === 'CONNECT') {
333
353
  session.ref()
334
- // We are already connected, streams are pending, first request
335
- // will create a new stream. We trigger a request to create the stream and wait until
336
- // `ready` event is triggered
337
354
  // We disabled endStream to allow the user to write to the stream
338
355
  stream = session.request(headers, { endStream: false, signal })
356
+ let upgradeResponseFinished = false
357
+
358
+ /**
359
+ * @param {import('node:http2').IncomingHttpHeaders} headers
360
+ */
361
+ const onResponse = (headers) => {
362
+ upgradeResponseFinished = true
363
+ stream.off(errorMonitor, onUpgradeError)
364
+ request.onUpgradeResponse(Number(headers[HTTP2_HEADER_STATUS]), headers, parseH2ResponseHeaders)
365
+ }
339
366
 
340
- if (stream.id && !stream.pending) {
341
- request.onUpgrade(null, null, stream)
342
- ++session[kOpenStreams]
343
- client[kQueue][client[kRunningIdx]++] = null
344
- } else {
345
- stream.once('ready', () => {
367
+ /**
368
+ * @param {Error} error
369
+ */
370
+ const onUpgradeError = (error) => {
371
+ upgradeResponseFinished = true
372
+ stream.off('response', onResponse)
373
+ request.onUpgradeError(error)
374
+ }
375
+
376
+ const onReady = () => {
377
+ try {
346
378
  request.onUpgrade(null, null, stream)
347
- ++session[kOpenStreams]
348
- client[kQueue][client[kRunningIdx]++] = null
349
- })
379
+ } catch (error) {
380
+ stream.off('response', onResponse)
381
+ abort(error)
382
+ return
383
+ }
384
+
385
+ if (request.aborted) {
386
+ return
387
+ }
388
+
389
+ stream.off('error', abort)
390
+ stream.once(errorMonitor, onUpgradeError)
391
+ client[kQueue][client[kRunningIdx]++] = null
350
392
  }
351
393
 
394
+ stream.once('response', onResponse)
395
+ stream.once('error', abort)
396
+ ++session[kOpenStreams]
397
+ onReady()
398
+
352
399
  stream.once('close', () => {
400
+ if (!upgradeResponseFinished && request.completed) {
401
+ stream.off('response', onResponse)
402
+ stream.off(errorMonitor, onUpgradeError)
403
+ request.onUpgradeError(new InformationalError(`HTTP/2: "stream error" received - code ${stream.rstCode}`))
404
+ }
353
405
  session[kOpenStreams] -= 1
354
406
  if (session[kOpenStreams] === 0) session.unref()
355
407
  })
@@ -205,7 +205,10 @@ class RetryHandler {
205
205
  this.retryCount += 1
206
206
 
207
207
  if (statusCode >= 300) {
208
- if (this.retryOpts.statusCodes.includes(statusCode) === false) {
208
+ // Only expose a response if no earlier attempt has reached the caller.
209
+ // Otherwise abort this attempt so the error settles the existing body
210
+ // instead of replacing it with a new response.
211
+ if (!this.headersSent && this.retryOpts.statusCodes.includes(statusCode) === false) {
209
212
  this.headersSent = true
210
213
  this.checkpointResponseEnd(headers, resume)
211
214
  return this.handler.onHeaders(
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "6.28.1",
3
+ "version": "6.29.0",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "./dist/node_modules/node-gyp/gyp/gyp"
10
10
  ]
11
11
  },
12
- "version": "12.8.0",
12
+ "version": "12.8.2",
13
13
  "description": "Fast, disk space efficient package manager",
14
14
  "keywords": [
15
15
  "pnpm",
@@ -17,7 +17,7 @@
17
17
  "rust"
18
18
  ],
19
19
  "license": "MIT",
20
- "homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm",
20
+ "homepage": "https://pnpm.io",
21
21
  "bugs": "https://github.com/pnpm/pnpm/issues",
22
22
  "repository": {
23
23
  "type": "git",
@@ -46,20 +46,20 @@
46
46
  "THIRD-PARTY-NOTICES.md"
47
47
  ],
48
48
  "optionalDependencies": {
49
- "@pnpm/exe.win32-x64": "12.8.0",
50
- "@pnpm/exe.win32-arm64": "12.8.0",
51
- "@pnpm/exe.darwin-x64": "12.8.0",
52
- "@pnpm/exe.darwin-arm64": "12.8.0",
53
- "@pnpm/exe.linux-x64": "12.8.0",
54
- "@pnpm/exe.linux-arm64": "12.8.0",
55
- "@pnpm/exe.linux-riscv64": "12.8.0",
56
- "@pnpm/exe.linux-ppc64": "12.8.0",
57
- "@pnpm/exe.linux-s390x": "12.8.0",
58
- "@pnpm/exe.linux-x64-musl": "12.8.0",
59
- "@pnpm/exe.linux-arm64-musl": "12.8.0",
60
- "@pnpm/exe.freebsd-x64": "12.8.0",
61
- "@pnpm/exe.android-arm64": "12.8.0",
62
- "@pnpm/exe.android-x64": "12.8.0"
49
+ "@pnpm/exe.win32-x64": "12.8.2",
50
+ "@pnpm/exe.win32-arm64": "12.8.2",
51
+ "@pnpm/exe.darwin-x64": "12.8.2",
52
+ "@pnpm/exe.darwin-arm64": "12.8.2",
53
+ "@pnpm/exe.linux-x64": "12.8.2",
54
+ "@pnpm/exe.linux-arm64": "12.8.2",
55
+ "@pnpm/exe.linux-riscv64": "12.8.2",
56
+ "@pnpm/exe.linux-ppc64": "12.8.2",
57
+ "@pnpm/exe.linux-s390x": "12.8.2",
58
+ "@pnpm/exe.linux-x64-musl": "12.8.2",
59
+ "@pnpm/exe.linux-arm64-musl": "12.8.2",
60
+ "@pnpm/exe.freebsd-x64": "12.8.2",
61
+ "@pnpm/exe.android-arm64": "12.8.2",
62
+ "@pnpm/exe.android-x64": "12.8.2"
63
63
  },
64
64
  "scripts": {
65
65
  "preinstall": "node install.js",
package/pn CHANGED
@@ -9,9 +9,8 @@
9
9
  # hang the script. Directories come from `${self%/*}` and `readlink` runs through
10
10
  # `command -p`, so the caller's `PATH` decides nothing here.
11
11
  #
12
- # Where no default path is compiled in, as on Nix, `command -p` searches PATH
13
- # instead, so the helpers run with node_modules and relative entries dropped from
14
- # PATH.
12
+ # A helper the default path lacks, as in a Nix build sandbox, comes from PATH
13
+ # instead, with node_modules and relative entries dropped from it.
15
14
  caller_path_set=${PATH+set}
16
15
  caller_path=${PATH-}
17
16
  helper_path=
@@ -26,6 +25,11 @@ while [ -n "$rest" ]; do
26
25
  done
27
26
  # An empty PATH searches the current directory.
28
27
  PATH=${helper_path:-/}
28
+ # A helper comes from PATH only when the default path lacks it and PATH has it.
29
+ # The bash 3.2 that macOS ships as sh answers `command -p -v` from PATH.
30
+ run_helper() {
31
+ if command -p -v "$1" >/dev/null 2>&1 || ! command -v "$1" >/dev/null 2>&1; then command -p "$@"; else command "$@"; fi
32
+ }
29
33
  self=$0
30
34
  # MSYS and Cygwin can launch this with a native Windows path, which has no slash
31
35
  # for `${self%/*}` to strip. Only a drive letter or a UNC prefix marks one; a
@@ -51,7 +55,7 @@ esac
51
55
  hops=0
52
56
  while [ -L "$self" ] && [ "$hops" -lt 40 ]; do
53
57
  hops=$((hops + 1))
54
- link=$(command -p readlink "$self")
58
+ link=$(run_helper readlink "$self")
55
59
  case $link in
56
60
  /*) self=$link ;;
57
61
  *) self=${self%/*}/$link ;;
package/pnpm CHANGED
@@ -29,9 +29,8 @@ fi
29
29
  # and directories come from `${self%/*}`, which runs nothing at all. The caller's
30
30
  # PATH therefore decides only which `node` runs, which is what it is for.
31
31
  #
32
- # Where no default path is compiled in, as on Nix, `command -p` searches PATH
33
- # instead, so the helpers run with node_modules and relative entries dropped from
34
- # PATH.
32
+ # A helper the default path lacks, as in a Nix build sandbox, comes from PATH
33
+ # instead, with node_modules and relative entries dropped from it.
35
34
  caller_path_set=${PATH+set}
36
35
  caller_path=${PATH-}
37
36
  helper_path=
@@ -46,6 +45,11 @@ while [ -n "$rest" ]; do
46
45
  done
47
46
  # An empty PATH searches the current directory.
48
47
  PATH=${helper_path:-/}
48
+ # A helper comes from PATH only when the default path lacks it and PATH has it.
49
+ # The bash 3.2 that macOS ships as sh answers `command -p -v` from PATH.
50
+ run_helper() {
51
+ if command -p -v "$1" >/dev/null 2>&1 || ! command -v "$1" >/dev/null 2>&1; then command -p "$@"; else command "$@"; fi
52
+ }
49
53
  self=$0
50
54
  # MSYS and Cygwin can launch this with a native Windows path, which has no slash
51
55
  # for `${self%/*}` to strip. Only a drive letter or a UNC prefix marks one; a
@@ -71,7 +75,7 @@ esac
71
75
  hops=0
72
76
  while [ -L "$self" ] && [ "$hops" -lt 40 ]; do
73
77
  hops=$((hops + 1))
74
- link=$(command -p readlink "$self")
78
+ link=$(run_helper readlink "$self")
75
79
  case $link in
76
80
  /*) self=$link ;;
77
81
  *) self=${self%/*}/$link ;;
package/pnpx CHANGED
@@ -9,9 +9,8 @@
9
9
  # hang the script. Directories come from `${self%/*}` and `readlink` runs through
10
10
  # `command -p`, so the caller's `PATH` decides nothing here.
11
11
  #
12
- # Where no default path is compiled in, as on Nix, `command -p` searches PATH
13
- # instead, so the helpers run with node_modules and relative entries dropped from
14
- # PATH.
12
+ # A helper the default path lacks, as in a Nix build sandbox, comes from PATH
13
+ # instead, with node_modules and relative entries dropped from it.
15
14
  caller_path_set=${PATH+set}
16
15
  caller_path=${PATH-}
17
16
  helper_path=
@@ -26,6 +25,11 @@ while [ -n "$rest" ]; do
26
25
  done
27
26
  # An empty PATH searches the current directory.
28
27
  PATH=${helper_path:-/}
28
+ # A helper comes from PATH only when the default path lacks it and PATH has it.
29
+ # The bash 3.2 that macOS ships as sh answers `command -p -v` from PATH.
30
+ run_helper() {
31
+ if command -p -v "$1" >/dev/null 2>&1 || ! command -v "$1" >/dev/null 2>&1; then command -p "$@"; else command "$@"; fi
32
+ }
29
33
  self=$0
30
34
  # MSYS and Cygwin can launch this with a native Windows path, which has no slash
31
35
  # for `${self%/*}` to strip. Only a drive letter or a UNC prefix marks one; a
@@ -51,7 +55,7 @@ esac
51
55
  hops=0
52
56
  while [ -L "$self" ] && [ "$hops" -lt 40 ]; do
53
57
  hops=$((hops + 1))
54
- link=$(command -p readlink "$self")
58
+ link=$(run_helper readlink "$self")
55
59
  case $link in
56
60
  /*) self=$link ;;
57
61
  *) self=${self%/*}/$link ;;
package/pnx CHANGED
@@ -9,9 +9,8 @@
9
9
  # hang the script. Directories come from `${self%/*}` and `readlink` runs through
10
10
  # `command -p`, so the caller's `PATH` decides nothing here.
11
11
  #
12
- # Where no default path is compiled in, as on Nix, `command -p` searches PATH
13
- # instead, so the helpers run with node_modules and relative entries dropped from
14
- # PATH.
12
+ # A helper the default path lacks, as in a Nix build sandbox, comes from PATH
13
+ # instead, with node_modules and relative entries dropped from it.
15
14
  caller_path_set=${PATH+set}
16
15
  caller_path=${PATH-}
17
16
  helper_path=
@@ -26,6 +25,11 @@ while [ -n "$rest" ]; do
26
25
  done
27
26
  # An empty PATH searches the current directory.
28
27
  PATH=${helper_path:-/}
28
+ # A helper comes from PATH only when the default path lacks it and PATH has it.
29
+ # The bash 3.2 that macOS ships as sh answers `command -p -v` from PATH.
30
+ run_helper() {
31
+ if command -p -v "$1" >/dev/null 2>&1 || ! command -v "$1" >/dev/null 2>&1; then command -p "$@"; else command "$@"; fi
32
+ }
29
33
  self=$0
30
34
  # MSYS and Cygwin can launch this with a native Windows path, which has no slash
31
35
  # for `${self%/*}` to strip. Only a drive letter or a UNC prefix marks one; a
@@ -51,7 +55,7 @@ esac
51
55
  hops=0
52
56
  while [ -L "$self" ] && [ "$hops" -lt 40 ]; do
53
57
  hops=$((hops + 1))
54
- link=$(command -p readlink "$self")
58
+ link=$(run_helper readlink "$self")
55
59
  case $link in
56
60
  /*) self=$link ;;
57
61
  *) self=${self%/*}/$link ;;