@pnpm/error 1100.1.4 → 1100.2.1
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 +12 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +41 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pnpm/error
|
|
2
2
|
|
|
3
|
+
## 1100.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `pnpm install` now works in StackBlitz WebContainers on projects without a lockfile. It used to fail there with `ENOENT ... pnpm-lock.yaml`, because pnpm did not recognize the errors that WebContainers return from asynchronous file system calls [#15649](https://github.com/pnpm/pnpm/issues/15649).
|
|
8
|
+
|
|
9
|
+
## 1100.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- When the registry stops sending data for longer than `fetchTimeout`, pnpm now reports that the metadata or tarball request timed out. Previously the error did not mention the timeout [#3646](https://github.com/pnpm/pnpm/issues/3646).
|
|
14
|
+
|
|
3
15
|
## 1100.1.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -27,6 +27,17 @@ export declare class FetchError extends PnpmError {
|
|
|
27
27
|
readonly request: FetchErrorRequest;
|
|
28
28
|
constructor(request: FetchErrorRequest, response: FetchErrorResponse, hint?: string);
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* undici fails a timed-out request with a bare `fetch failed` or `terminated`
|
|
32
|
+
* and keeps the timeout only in the error's `cause` chain.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isFetchTimeoutError(error: unknown): boolean;
|
|
35
|
+
export declare class FetchTimeoutError extends PnpmError {
|
|
36
|
+
constructor(code: string, url: string, timeout: number | undefined, opts: {
|
|
37
|
+
attempts?: number;
|
|
38
|
+
cause: unknown;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
30
41
|
export declare function redactUrlCredentials(text: string): string;
|
|
31
42
|
/**
|
|
32
43
|
* Make untrusted, URL-bearing text safe to print or log: redact inline
|
|
@@ -57,3 +68,13 @@ export declare function redactAndSanitizeMultiline(text: string): string;
|
|
|
57
68
|
export declare class LockfileMissingDependencyError extends PnpmError {
|
|
58
69
|
constructor(depPath: string);
|
|
59
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether `value` is an `Error`, whichever way the runtime created it.
|
|
73
|
+
*
|
|
74
|
+
* `util.types.isNativeError` misses the errors that StackBlitz WebContainers
|
|
75
|
+
* reject asynchronous `fs` calls with: they inherit from `Error`, but the
|
|
76
|
+
* native constructor did not create them. `instanceof Error` misses errors
|
|
77
|
+
* from another realm, such as the ones code under Jest's VM contexts catches.
|
|
78
|
+
* Either check passing is enough.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isError(value: unknown): value is Error;
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import util from 'node:util';
|
|
1
2
|
import { WANTED_LOCKFILE } from '@pnpm/constants';
|
|
2
3
|
export class PnpmError extends Error {
|
|
3
4
|
code;
|
|
@@ -39,6 +40,34 @@ export class FetchError extends PnpmError {
|
|
|
39
40
|
this.response = response;
|
|
40
41
|
}
|
|
41
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* undici codes for a request that made no progress for `fetchTimeout`: no
|
|
45
|
+
* response head, or a body that stopped arriving.
|
|
46
|
+
*/
|
|
47
|
+
const FETCH_TIMEOUT_ERROR_CODES = new Set(['UND_ERR_HEADERS_TIMEOUT', 'UND_ERR_BODY_TIMEOUT']);
|
|
48
|
+
/**
|
|
49
|
+
* undici fails a timed-out request with a bare `fetch failed` or `terminated`
|
|
50
|
+
* and keeps the timeout only in the error's `cause` chain.
|
|
51
|
+
*/
|
|
52
|
+
export function isFetchTimeoutError(error) {
|
|
53
|
+
let current = error;
|
|
54
|
+
for (let depth = 0; depth < 8 && current != null && typeof current === 'object'; depth++) {
|
|
55
|
+
const { code, cause } = current;
|
|
56
|
+
if (typeof code === 'string' && FETCH_TIMEOUT_ERROR_CODES.has(code))
|
|
57
|
+
return true;
|
|
58
|
+
current = cause;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
export class FetchTimeoutError extends PnpmError {
|
|
63
|
+
constructor(code, url, timeout, opts) {
|
|
64
|
+
const reason = timeout == null ? 'waiting for data' : `no data received for ${timeout}ms`;
|
|
65
|
+
super(code, `GET ${redactUrlForDisplay(url)}: timed out, ${reason}`, {
|
|
66
|
+
...opts,
|
|
67
|
+
hint: 'The registry stopped responding. If it is just slow, increase the fetchTimeout setting.',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
42
71
|
/**
|
|
43
72
|
* Strip `user:pass@` (or `user@`) userinfo that follows a URL scheme in any
|
|
44
73
|
* text, e.g. `GET https://user:pass@host/pkg: …` → `GET https://host/pkg: …`.
|
|
@@ -191,4 +220,16 @@ export class LockfileMissingDependencyError extends PnpmError {
|
|
|
191
220
|
});
|
|
192
221
|
}
|
|
193
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Whether `value` is an `Error`, whichever way the runtime created it.
|
|
225
|
+
*
|
|
226
|
+
* `util.types.isNativeError` misses the errors that StackBlitz WebContainers
|
|
227
|
+
* reject asynchronous `fs` calls with: they inherit from `Error`, but the
|
|
228
|
+
* native constructor did not create them. `instanceof Error` misses errors
|
|
229
|
+
* from another realm, such as the ones code under Jest's VM contexts catches.
|
|
230
|
+
* Either check passing is enough.
|
|
231
|
+
*/
|
|
232
|
+
export function isError(value) {
|
|
233
|
+
return util.types.isNativeError(value) || value instanceof Error;
|
|
234
|
+
}
|
|
194
235
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/error",
|
|
3
|
-
"version": "1100.1
|
|
3
|
+
"version": "1100.2.1",
|
|
4
4
|
"description": "An error class for pnpm errors",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@jest/globals": "30.4.1",
|
|
35
|
-
"@pnpm/error": "1100.1
|
|
35
|
+
"@pnpm/error": "1100.2.1"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.13"
|