@pnpm/error 1100.1.4 → 1100.2.0
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 +6 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +28 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @pnpm/error
|
|
2
2
|
|
|
3
|
+
## 1100.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 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).
|
|
8
|
+
|
|
3
9
|
## 1100.1.4
|
|
4
10
|
|
|
5
11
|
### 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
|
package/lib/index.js
CHANGED
|
@@ -39,6 +39,34 @@ export class FetchError extends PnpmError {
|
|
|
39
39
|
this.response = response;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* undici codes for a request that made no progress for `fetchTimeout`: no
|
|
44
|
+
* response head, or a body that stopped arriving.
|
|
45
|
+
*/
|
|
46
|
+
const FETCH_TIMEOUT_ERROR_CODES = new Set(['UND_ERR_HEADERS_TIMEOUT', 'UND_ERR_BODY_TIMEOUT']);
|
|
47
|
+
/**
|
|
48
|
+
* undici fails a timed-out request with a bare `fetch failed` or `terminated`
|
|
49
|
+
* and keeps the timeout only in the error's `cause` chain.
|
|
50
|
+
*/
|
|
51
|
+
export function isFetchTimeoutError(error) {
|
|
52
|
+
let current = error;
|
|
53
|
+
for (let depth = 0; depth < 8 && current != null && typeof current === 'object'; depth++) {
|
|
54
|
+
const { code, cause } = current;
|
|
55
|
+
if (typeof code === 'string' && FETCH_TIMEOUT_ERROR_CODES.has(code))
|
|
56
|
+
return true;
|
|
57
|
+
current = cause;
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
export class FetchTimeoutError extends PnpmError {
|
|
62
|
+
constructor(code, url, timeout, opts) {
|
|
63
|
+
const reason = timeout == null ? 'waiting for data' : `no data received for ${timeout}ms`;
|
|
64
|
+
super(code, `GET ${redactUrlForDisplay(url)}: timed out, ${reason}`, {
|
|
65
|
+
...opts,
|
|
66
|
+
hint: 'The registry stopped responding. If it is just slow, increase the fetchTimeout setting.',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
42
70
|
/**
|
|
43
71
|
* Strip `user:pass@` (or `user@`) userinfo that follows a URL scheme in any
|
|
44
72
|
* text, e.g. `GET https://user:pass@host/pkg: …` → `GET https://host/pkg: …`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/error",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.2.0",
|
|
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.
|
|
35
|
+
"@pnpm/error": "1100.2.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.13"
|