@common.js/is-network-error 1.1.0 → 1.3.3
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/README.md +1 -1
- package/index.js +17 -8
- package/package.json +15 -3
package/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
The [is-network-error](https://www.npmjs.com/package/is-network-error) package exported as CommonJS modules.
|
|
4
4
|
|
|
5
|
-
Exported from [is-network-error@1.
|
|
5
|
+
Exported from [is-network-error@1.3.2](https://www.npmjs.com/package/is-network-error/v/1.3.2) using https://github.com/etienne-martin/common.js.
|
package/index.js
CHANGED
|
@@ -14,23 +14,32 @@ var isError = function(value) {
|
|
|
14
14
|
};
|
|
15
15
|
var errorMessages = new Set([
|
|
16
16
|
"network error",
|
|
17
|
-
"Failed to fetch",
|
|
18
17
|
"NetworkError when attempting to fetch resource.",
|
|
19
18
|
"The Internet connection appears to be offline.",
|
|
20
|
-
"Load failed",
|
|
21
19
|
"Network request failed",
|
|
22
20
|
"fetch failed",
|
|
23
|
-
"terminated"
|
|
21
|
+
"terminated",
|
|
22
|
+
" A network error occurred.",
|
|
23
|
+
"Network connection lost"
|
|
24
24
|
]);
|
|
25
25
|
function isNetworkError(error) {
|
|
26
26
|
var isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
|
|
27
27
|
if (!isValid) {
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
30
|
+
var message = error.message, stack = error.stack;
|
|
31
|
+
// Safari 17+ has generic message but no stack for network errors
|
|
32
|
+
if (message === "Load failed" || message.startsWith("Load failed (") && message.endsWith(")")) {
|
|
33
|
+
return stack === undefined || "__sentry_captured__" in error;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
// Deno network errors start with specific text
|
|
36
|
+
if (message.startsWith("error sending request for url")) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
// Chrome: exact "Failed to fetch" or with hostname: "Failed to fetch (example.com)"
|
|
40
|
+
if (message === "Failed to fetch" || message.startsWith("Failed to fetch (") && message.endsWith(")")) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
// Standard network error messages
|
|
44
|
+
return errorMessages.has(message);
|
|
36
45
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common.js/is-network-error",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "is-network-error package exported as CommonJS modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "etienne-martin/common.js",
|
|
7
7
|
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
8
|
"type": "commonjs",
|
|
9
|
+
"exports": {
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"default": "./index.js"
|
|
12
|
+
},
|
|
9
13
|
"sideEffects": false,
|
|
10
14
|
"engines": {
|
|
11
15
|
"node": ">=16"
|
|
@@ -24,6 +28,14 @@
|
|
|
24
28
|
},
|
|
25
29
|
"homepage": "https://github.com/etienne-martin/common.js#readme",
|
|
26
30
|
"dependencies": {},
|
|
27
|
-
"
|
|
28
|
-
|
|
31
|
+
"commonjs": {
|
|
32
|
+
"source": {
|
|
33
|
+
"name": "is-network-error",
|
|
34
|
+
"version": "1.3.2"
|
|
35
|
+
},
|
|
36
|
+
"transformRevision": 1,
|
|
37
|
+
"buildKey": "4e22d6726feb4762b92a3a8b96938f987e2e2ea3166fb7defa9d4a0bbe617171"
|
|
38
|
+
},
|
|
39
|
+
"main": "./index.js",
|
|
40
|
+
"types": "./index.d.ts"
|
|
29
41
|
}
|